From 464915d2cc78c996bb12c6b3911214bd8f10ad28 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 29 Sep 2016 13:21:54 +0100 Subject: [PATCH 1/2] Remove support for HornetQ following its deprecation in 1.4 See gh-6971 --- spring-boot-autoconfigure/pom.xml | 15 +- .../jms/hornetq/HornetQAutoConfiguration.java | 58 --- .../HornetQConfigurationCustomizer.java | 41 -- ...HornetQConnectionFactoryConfiguration.java | 47 -- .../HornetQConnectionFactoryFactory.java | 142 ------ .../HornetQEmbeddedConfigurationFactory.java | 90 ---- .../HornetQEmbeddedServerConfiguration.java | 130 ------ .../jms/hornetq/HornetQMode.java | 39 -- .../hornetq/HornetQNoOpBindingRegistry.java | 66 --- .../jms/hornetq/HornetQProperties.java | 230 --------- ...rnetQXAConnectionFactoryConfiguration.java | 64 --- .../SpringBootHornetQConnectionFactory.java | 61 --- .../SpringBootHornetQXAConnectionFactory.java | 61 --- .../jms/hornetq/package-info.java | 21 - .../transaction/jta/JtaAutoConfiguration.java | 6 +- .../main/resources/META-INF/spring.factories | 1 - .../HornetQAutoConfigurationTests.java | 435 ------------------ ...netQEmbeddedConfigurationFactoryTests.java | 71 --- .../src/test/resources/application.properties | 1 - spring-boot-dependencies/pom.xml | 22 - spring-boot-docs/pom.xml | 5 - .../appendix-application-properties.adoc | 14 - .../main/asciidoc/spring-boot-features.adoc | 54 --- spring-boot-samples/README.adoc | 3 - spring-boot-samples/pom.xml | 1 - .../spring-boot-sample-hornetq/pom.xml | 44 -- .../hornetq/SampleHornetQApplication.java | 65 --- .../src/main/java/sample/hornetq/Sender.java | 35 -- .../src/main/resources/application.properties | 3 - spring-boot-starters/pom.xml | 1 - .../spring-boot-starter-hornetq/pom.xml | 57 --- ...erDeprecationWarningAutoConfiguration.java | 47 -- .../main/resources/META-INF/spring.factories | 3 - .../main/resources/META-INF/spring.provides | 1 - 34 files changed, 7 insertions(+), 1927 deletions(-) delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfiguration.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConfigurationCustomizer.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConnectionFactoryConfiguration.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConnectionFactoryFactory.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedConfigurationFactory.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedServerConfiguration.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQMode.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQNoOpBindingRegistry.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQProperties.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQXAConnectionFactoryConfiguration.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/SpringBootHornetQConnectionFactory.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/SpringBootHornetQXAConnectionFactory.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/package-info.java delete mode 100644 spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfigurationTests.java delete mode 100644 spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedConfigurationFactoryTests.java delete mode 100644 spring-boot-samples/spring-boot-sample-hornetq/pom.xml delete mode 100644 spring-boot-samples/spring-boot-sample-hornetq/src/main/java/sample/hornetq/SampleHornetQApplication.java delete mode 100644 spring-boot-samples/spring-boot-sample-hornetq/src/main/java/sample/hornetq/Sender.java delete mode 100644 spring-boot-samples/spring-boot-sample-hornetq/src/main/resources/application.properties delete mode 100644 spring-boot-starters/spring-boot-starter-hornetq/pom.xml delete mode 100644 spring-boot-starters/spring-boot-starter-hornetq/src/main/java/org/springframework/boot/starter/hornetq/HornetQStarterDeprecationWarningAutoConfiguration.java delete mode 100644 spring-boot-starters/spring-boot-starter-hornetq/src/main/resources/META-INF/spring.factories delete mode 100644 spring-boot-starters/spring-boot-starter-hornetq/src/main/resources/META-INF/spring.provides diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml index 25ba35ea579..a3ff5fdb70e 100755 --- a/spring-boot-autoconfigure/pom.xml +++ b/spring-boot-autoconfigure/pom.xml @@ -270,16 +270,6 @@ hibernate-validator true - - org.hornetq - hornetq-jms-client - true - - - org.hornetq - hornetq-jms-server - true - org.infinispan infinispan-jcache @@ -290,6 +280,11 @@ infinispan-spring4-embedded true + + org.jboss + jboss-transaction-spi + true + org.springframework spring-jdbc diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfiguration.java deleted file mode 100644 index 115e3ad2390..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfiguration.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.jms.hornetq; - -import javax.jms.ConnectionFactory; - -import org.hornetq.api.jms.HornetQJMSClient; - -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; -import org.springframework.boot.autoconfigure.jms.JndiConnectionFactoryAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - -/** - * {@link EnableAutoConfiguration Auto-configuration} to integrate with an HornetQ broker. - * If the necessary classes are present, embed the broker in the application by default. - * Otherwise, connect to a broker available on the local machine with the default - * settings. - * - * @author Stephane Nicoll - * @author Phillip Webb - * @since 1.1.0 - * @see HornetQProperties - * @deprecated as of 1.4 in favor of the Artemis support - */ -@Configuration -@AutoConfigureBefore(JmsAutoConfiguration.class) -@AutoConfigureAfter({ JndiConnectionFactoryAutoConfiguration.class }) -@ConditionalOnClass({ ConnectionFactory.class, HornetQJMSClient.class }) -@ConditionalOnMissingBean(ConnectionFactory.class) -@EnableConfigurationProperties(HornetQProperties.class) -@Import({ HornetQEmbeddedServerConfiguration.class, - HornetQXAConnectionFactoryConfiguration.class, - HornetQConnectionFactoryConfiguration.class }) -@Deprecated -public class HornetQAutoConfiguration { - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConfigurationCustomizer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConfigurationCustomizer.java deleted file mode 100644 index 9dfc4d78d3f..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConfigurationCustomizer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.jms.hornetq; - -import org.hornetq.core.config.Configuration; -import org.hornetq.jms.server.embedded.EmbeddedJMS; - -/** - * Callback interface that can be implemented by beans wishing to customize the HornetQ - * JMS server {@link Configuration} before it is used by an auto-configured - * {@link EmbeddedJMS} instance. - * - * @author Phillip Webb - * @since 1.1.0 - * @see HornetQAutoConfiguration - * @deprecated as of 1.4 in favor of the Artemis support - */ -@Deprecated -public interface HornetQConfigurationCustomizer { - - /** - * Customize the configuration. - * @param configuration the configuration to customize - */ - void customize(Configuration configuration); - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConnectionFactoryConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConnectionFactoryConfiguration.java deleted file mode 100644 index 50247e94cae..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConnectionFactoryConfiguration.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.jms.hornetq; - -import javax.jms.ConnectionFactory; - -import org.hornetq.jms.client.HornetQConnectionFactory; - -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * Configuration for HornetQ {@link ConnectionFactory}. - * - * @author Phillip Webb - * @since 1.2.0 - * @deprecated as of 1.4 in favor of the Artemis support - */ -@Configuration -@ConditionalOnMissingBean(ConnectionFactory.class) -@Deprecated -class HornetQConnectionFactoryConfiguration { - - @Bean - public HornetQConnectionFactory jmsConnectionFactory(ListableBeanFactory beanFactory, - HornetQProperties properties) { - return new HornetQConnectionFactoryFactory(beanFactory, properties) - .createConnectionFactory(SpringBootHornetQConnectionFactory.class); - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConnectionFactoryFactory.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConnectionFactoryFactory.java deleted file mode 100644 index a20dd785f52..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQConnectionFactoryFactory.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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.jms.hornetq; - -import java.lang.reflect.Constructor; -import java.util.HashMap; -import java.util.Map; - -import org.hornetq.api.core.TransportConfiguration; -import org.hornetq.api.core.client.HornetQClient; -import org.hornetq.api.core.client.ServerLocator; -import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory; -import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory; -import org.hornetq.core.remoting.impl.netty.TransportConstants; -import org.hornetq.jms.client.HornetQConnectionFactory; - -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; - -/** - * Factory to create a {@link HornetQConnectionFactory} instance from properties defined - * in {@link HornetQProperties}. - * - * @author Phillip Webb - * @author Stephane Nicoll - * @since 1.2.0 - * @deprecated as of 1.4 in favor of the Artemis support - */ -@Deprecated -class HornetQConnectionFactoryFactory { - - static final String EMBEDDED_JMS_CLASS = "org.hornetq.jms.server.embedded.EmbeddedJMS"; - - private final HornetQProperties properties; - - private final ListableBeanFactory beanFactory; - - HornetQConnectionFactoryFactory(ListableBeanFactory beanFactory, - HornetQProperties properties) { - Assert.notNull(beanFactory, "BeanFactory must not be null"); - Assert.notNull(properties, "Properties must not be null"); - this.beanFactory = beanFactory; - this.properties = properties; - } - - public T createConnectionFactory( - Class factoryClass) { - try { - startEmbeddedJms(); - return doCreateConnectionFactory(factoryClass); - } - catch (Exception ex) { - throw new IllegalStateException( - "Unable to create " + "HornetQConnectionFactory", ex); - } - } - - private void startEmbeddedJms() { - if (ClassUtils.isPresent(EMBEDDED_JMS_CLASS, null)) { - try { - this.beanFactory.getBeansOfType(Class.forName(EMBEDDED_JMS_CLASS)); - } - catch (Exception ex) { - // Ignore - } - } - } - - private T doCreateConnectionFactory( - Class factoryClass) throws Exception { - HornetQMode mode = this.properties.getMode(); - if (mode == null) { - mode = deduceMode(); - } - if (mode == HornetQMode.EMBEDDED) { - return createEmbeddedConnectionFactory(factoryClass); - } - return createNativeConnectionFactory(factoryClass); - } - - /** - * Deduce the {@link HornetQMode} to use if none has been set. - * @return the mode - */ - private HornetQMode deduceMode() { - if (this.properties.getEmbedded().isEnabled() - && ClassUtils.isPresent(EMBEDDED_JMS_CLASS, null)) { - return HornetQMode.EMBEDDED; - } - return HornetQMode.NATIVE; - } - - private T createEmbeddedConnectionFactory( - Class factoryClass) throws Exception { - try { - TransportConfiguration transportConfiguration = new TransportConfiguration( - InVMConnectorFactory.class.getName(), - this.properties.getEmbedded().generateTransportParameters()); - ServerLocator serviceLocator = HornetQClient - .createServerLocatorWithoutHA(transportConfiguration); - Constructor constructor = factoryClass - .getDeclaredConstructor(HornetQProperties.class, ServerLocator.class); - return BeanUtils.instantiateClass(constructor, this.properties, - serviceLocator); - } - catch (NoClassDefFoundError ex) { - throw new IllegalStateException("Unable to create InVM " - + "HornetQ connection, ensure that hornet-jms-server.jar " - + "is in the classpath", ex); - } - } - - private T createNativeConnectionFactory( - Class factoryClass) throws Exception { - Map params = new HashMap(); - params.put(TransportConstants.HOST_PROP_NAME, this.properties.getHost()); - params.put(TransportConstants.PORT_PROP_NAME, this.properties.getPort()); - TransportConfiguration transportConfiguration = new TransportConfiguration( - NettyConnectorFactory.class.getName(), params); - Constructor constructor = factoryClass.getDeclaredConstructor( - HornetQProperties.class, boolean.class, TransportConfiguration[].class); - return BeanUtils.instantiateClass(constructor, this.properties, false, - new TransportConfiguration[] { transportConfiguration }); - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedConfigurationFactory.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedConfigurationFactory.java deleted file mode 100644 index 8208bf97efc..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedConfigurationFactory.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.jms.hornetq; - -import java.io.File; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hornetq.api.core.TransportConfiguration; -import org.hornetq.core.config.Configuration; -import org.hornetq.core.config.impl.ConfigurationImpl; -import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory; -import org.hornetq.core.server.JournalType; - -import org.springframework.boot.autoconfigure.jms.hornetq.HornetQProperties.Embedded; - -/** - * Factory class to create a HornetQ {@link Configuration} from {@link HornetQProperties}. - * - * @author Stephane Nicoll - * @author Phillip Webb - * @since 1.1.0 - * @deprecated as of 1.4 in favor of the Artemis support - */ -@Deprecated -class HornetQEmbeddedConfigurationFactory { - - private static final Log logger = LogFactory - .getLog(HornetQEmbeddedConfigurationFactory.class); - - private final Embedded properties; - - HornetQEmbeddedConfigurationFactory(HornetQProperties properties) { - this.properties = properties.getEmbedded(); - } - - public Configuration createConfiguration() { - ConfigurationImpl configuration = new ConfigurationImpl(); - configuration.setSecurityEnabled(false); - configuration.setPersistenceEnabled(this.properties.isPersistent()); - - String dataDir = getDataDir(); - - // HORNETQ-1302 - configuration.setJournalDirectory(dataDir + "/journal"); - - if (this.properties.isPersistent()) { - configuration.setJournalType(JournalType.NIO); - configuration.setLargeMessagesDirectory(dataDir + "/largemessages"); - configuration.setBindingsDirectory(dataDir + "/bindings"); - configuration.setPagingDirectory(dataDir + "/paging"); - } - - TransportConfiguration transportConfiguration = new TransportConfiguration( - InVMAcceptorFactory.class.getName(), - this.properties.generateTransportParameters()); - configuration.getAcceptorConfigurations().add(transportConfiguration); - - // HORNETQ-1143 - if (this.properties.isDefaultClusterPassword()) { - logger.debug("Using default HornetQ cluster password: " - + this.properties.getClusterPassword()); - } - - configuration.setClusterPassword(this.properties.getClusterPassword()); - return configuration; - } - - private String getDataDir() { - if (this.properties.getDataDirectory() != null) { - return this.properties.getDataDirectory(); - } - String tempDirectory = System.getProperty("java.io.tmpdir"); - return new File(tempDirectory, "hornetq-data").getAbsolutePath(); - } -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedServerConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedServerConfiguration.java deleted file mode 100644 index 4cd8efbc86e..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedServerConfiguration.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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.jms.hornetq; - -import java.util.Collection; -import java.util.List; - -import org.hornetq.jms.server.config.JMSConfiguration; -import org.hornetq.jms.server.config.JMSQueueConfiguration; -import org.hornetq.jms.server.config.TopicConfiguration; -import org.hornetq.jms.server.config.impl.JMSConfigurationImpl; -import org.hornetq.jms.server.config.impl.JMSQueueConfigurationImpl; -import org.hornetq.jms.server.config.impl.TopicConfigurationImpl; -import org.hornetq.jms.server.embedded.EmbeddedJMS; - -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.annotation.AnnotationAwareOrderComparator; - -/** - * Configuration used to create the embedded HornetQ server. - * - * @author Phillip Webb - * @author Stephane Nicoll - * @since 1.2.0 - * @deprecated as of 1.4 in favor of the Artemis support - */ -@Configuration -@ConditionalOnClass(name = HornetQConnectionFactoryFactory.EMBEDDED_JMS_CLASS) -@ConditionalOnProperty(prefix = "spring.hornetq.embedded", name = "enabled", havingValue = "true", matchIfMissing = true) -@Deprecated -class HornetQEmbeddedServerConfiguration { - - private final HornetQProperties properties; - - private final List configurationCustomizers; - - private final List queuesConfiguration; - - private final List topicsConfiguration; - - HornetQEmbeddedServerConfiguration(HornetQProperties properties, - ObjectProvider> configurationCustomizersProvider, - ObjectProvider> queuesConfigurationProvider, - ObjectProvider> topicsConfigurationProvider) { - this.properties = properties; - this.configurationCustomizers = configurationCustomizersProvider.getIfAvailable(); - this.queuesConfiguration = queuesConfigurationProvider.getIfAvailable(); - this.topicsConfiguration = topicsConfigurationProvider.getIfAvailable(); - } - - @Bean - @ConditionalOnMissingBean - public org.hornetq.core.config.Configuration hornetQConfiguration() { - return new HornetQEmbeddedConfigurationFactory(this.properties) - .createConfiguration(); - } - - @Bean(initMethod = "start", destroyMethod = "stop") - @ConditionalOnMissingBean - public EmbeddedJMS hornetQServer(org.hornetq.core.config.Configuration configuration, - JMSConfiguration jmsConfiguration) { - EmbeddedJMS server = new EmbeddedJMS(); - customize(configuration); - server.setConfiguration(configuration); - server.setJmsConfiguration(jmsConfiguration); - server.setRegistry(new HornetQNoOpBindingRegistry()); - return server; - } - - private void customize(org.hornetq.core.config.Configuration configuration) { - if (this.configurationCustomizers != null) { - AnnotationAwareOrderComparator.sort(this.configurationCustomizers); - for (HornetQConfigurationCustomizer customizer : this.configurationCustomizers) { - customizer.customize(configuration); - } - } - } - - @Bean - @ConditionalOnMissingBean - public JMSConfiguration hornetQJmsConfiguration() { - JMSConfiguration configuration = new JMSConfigurationImpl(); - addAll(configuration.getQueueConfigurations(), this.queuesConfiguration); - addAll(configuration.getTopicConfigurations(), this.topicsConfiguration); - addQueues(configuration, this.properties.getEmbedded().getQueues()); - addTopics(configuration, this.properties.getEmbedded().getTopics()); - return configuration; - } - - private void addAll(List list, Collection items) { - if (items != null) { - list.addAll(items); - } - } - - private void addQueues(JMSConfiguration configuration, String[] queues) { - boolean persistent = this.properties.getEmbedded().isPersistent(); - for (String queue : queues) { - configuration.getQueueConfigurations().add(new JMSQueueConfigurationImpl( - queue, null, persistent, "/queue/" + queue)); - } - } - - private void addTopics(JMSConfiguration configuration, String[] topics) { - for (String topic : topics) { - configuration.getTopicConfigurations() - .add(new TopicConfigurationImpl(topic, "/topic/" + topic)); - } - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQMode.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQMode.java deleted file mode 100644 index ab900684e0f..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQMode.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.jms.hornetq; - -/** - * Define the mode in which HornetQ can operate. - * - * @author Stephane Nicoll - * @since 1.1.0 - * @deprecated as of 1.4 in favor of the Artemis support - */ -@Deprecated -public enum HornetQMode { - - /** - * Connect to a broker using the native HornetQ protocol (i.e. netty). - */ - NATIVE, - - /** - * Embed (i.e. start) the broker in the application. - */ - EMBEDDED - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQNoOpBindingRegistry.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQNoOpBindingRegistry.java deleted file mode 100644 index 22c2e249bd5..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQNoOpBindingRegistry.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.jms.hornetq; - -import org.hornetq.spi.core.naming.BindingRegistry; - -/** - * A no-op implementation of the {@link org.hornetq.spi.core.naming.BindingRegistry}. - * - * @author Stephane Nicoll - * @since 1.1.0 - * @deprecated as of 1.4 in favor of the Artemis support - */ -@Deprecated -public class HornetQNoOpBindingRegistry implements BindingRegistry { - - @Override - public Object lookup(String name) { - // This callback is used to check if an entry is present in the context before - // creating a queue on the fly. This is actually never used to try to fetch a - // destination that is unknown. - return null; - } - - @Override - public boolean bind(String name, Object obj) { - // This callback is used bind a Destination created on the fly by the embedded - // broker using the JNDI name that was specified in the configuration. This does - // not look very useful since it's used nowhere. It could be interesting to - // autowire a destination to use it but the wiring is a bit "asynchronous" so - // better not provide that feature at all. - return false; - } - - @Override - public void unbind(String name) { - } - - @Override - public void close() { - } - - @Override - public Object getContext() { - return this; - } - - @Override - public void setContext(Object ctx) { - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQProperties.java deleted file mode 100644 index 69800d8cf70..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQProperties.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * 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.jms.hornetq; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; - -import org.hornetq.core.remoting.impl.invm.TransportConstants; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Configuration properties for HornetQ. - * - * @author Stephane Nicoll - * @since 1.1.0 - * @deprecated as of 1.4 in favor of the Artemis support - */ -@ConfigurationProperties(prefix = "spring.hornetq") -@Deprecated -public class HornetQProperties { - - /** - * HornetQ deployment mode, auto-detected by default. - */ - private HornetQMode mode; - - /** - * HornetQ broker host. - */ - private String host = "localhost"; - - /** - * HornetQ broker port. - */ - private int port = 5445; - - /** - * Login user of the broker. - */ - private String user; - - /** - * Login password of the broker. - */ - private String password; - - private final Embedded embedded = new Embedded(); - - public HornetQMode getMode() { - return this.mode; - } - - public void setMode(HornetQMode mode) { - this.mode = mode; - } - - public String getHost() { - return this.host; - } - - public void setHost(String host) { - this.host = host; - } - - public int getPort() { - return this.port; - } - - public void setPort(int port) { - this.port = port; - } - - 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 Embedded getEmbedded() { - return this.embedded; - } - - /** - * Configuration for an embedded HornetQ server. - */ - public static class Embedded { - - private static final AtomicInteger serverIdCounter = new AtomicInteger(); - - /** - * Server id. By default, an auto-incremented counter is used. - */ - private int serverId = serverIdCounter.getAndIncrement(); - - /** - * Enable embedded mode if the HornetQ server APIs are available. - */ - private boolean enabled = true; - - /** - * Enable persistent store. - */ - private boolean persistent; - - /** - * Journal file directory. Not necessary if persistence is turned off. - */ - private String dataDirectory; - - /** - * Comma-separated list of queues to create on startup. - */ - private String[] queues = new String[0]; - - /** - * Comma-separated list of topics to create on startup. - */ - private String[] topics = new String[0]; - - /** - * Cluster password. Randomly generated on startup by default. - */ - private String clusterPassword = UUID.randomUUID().toString(); - - private boolean defaultClusterPassword = true; - - public int getServerId() { - return this.serverId; - } - - public void setServerId(int serverId) { - this.serverId = serverId; - } - - public boolean isEnabled() { - return this.enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public boolean isPersistent() { - return this.persistent; - } - - public void setPersistent(boolean persistent) { - this.persistent = persistent; - } - - public String getDataDirectory() { - return this.dataDirectory; - } - - public void setDataDirectory(String dataDirectory) { - this.dataDirectory = dataDirectory; - } - - public String[] getQueues() { - return this.queues; - } - - public void setQueues(String[] queues) { - this.queues = queues; - } - - public String[] getTopics() { - return this.topics; - } - - public void setTopics(String[] topics) { - this.topics = topics; - } - - public String getClusterPassword() { - return this.clusterPassword; - } - - public void setClusterPassword(String clusterPassword) { - this.clusterPassword = clusterPassword; - this.defaultClusterPassword = false; - } - - public boolean isDefaultClusterPassword() { - return this.defaultClusterPassword; - } - - /** - * Creates the minimal transport parameters for an embedded transport - * configuration. - * - * @return the transport parameters - * @see TransportConstants#SERVER_ID_PROP_NAME - */ - public Map generateTransportParameters() { - Map parameters = new HashMap(); - parameters.put(TransportConstants.SERVER_ID_PROP_NAME, getServerId()); - return parameters; - } - - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQXAConnectionFactoryConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQXAConnectionFactoryConfiguration.java deleted file mode 100644 index bd5b92b1b94..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQXAConnectionFactoryConfiguration.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.jms.hornetq; - -import javax.jms.ConnectionFactory; -import javax.transaction.TransactionManager; - -import org.hornetq.jms.client.HornetQConnectionFactory; - -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.jta.XAConnectionFactoryWrapper; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; - -/** - * Configuration for HornetQ XA {@link ConnectionFactory}. - * - * @author Phillip Webb - * @since 1.2.0 - * @deprecated as of 1.4 in favor of the Artemis support - */ -@Configuration -@ConditionalOnMissingBean(ConnectionFactory.class) -@ConditionalOnClass(TransactionManager.class) -@ConditionalOnBean(XAConnectionFactoryWrapper.class) -@Deprecated -class HornetQXAConnectionFactoryConfiguration { - - @Primary - @Bean(name = { "jmsConnectionFactory", "xaJmsConnectionFactory" }) - public ConnectionFactory jmsConnectionFactory(ListableBeanFactory beanFactory, - HornetQProperties properties, XAConnectionFactoryWrapper wrapper) - throws Exception { - return wrapper.wrapConnectionFactory( - new HornetQConnectionFactoryFactory(beanFactory, properties) - .createConnectionFactory( - SpringBootHornetQXAConnectionFactory.class)); - } - - @Bean - public HornetQConnectionFactory nonXaJmsConnectionFactory( - ListableBeanFactory beanFactory, HornetQProperties properties) { - return new HornetQConnectionFactoryFactory(beanFactory, properties) - .createConnectionFactory(SpringBootHornetQConnectionFactory.class); - } -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/SpringBootHornetQConnectionFactory.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/SpringBootHornetQConnectionFactory.java deleted file mode 100644 index bce572f93cf..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/SpringBootHornetQConnectionFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.jms.hornetq; - -import javax.jms.Connection; -import javax.jms.JMSException; - -import org.hornetq.api.core.TransportConfiguration; -import org.hornetq.api.core.client.ServerLocator; -import org.hornetq.jms.client.HornetQConnectionFactory; - -import org.springframework.util.StringUtils; - -/** - * A {@link HornetQConnectionFactory} that manages the credentials of the connection. - * - * @author Stéphane Lagraulet - * @author Stephane Nicoll - * @deprecated as of 1.4 in favor of the Artemis support - */ -@Deprecated -class SpringBootHornetQConnectionFactory extends HornetQConnectionFactory { - - private final HornetQProperties properties; - - SpringBootHornetQConnectionFactory(HornetQProperties properties, - ServerLocator serverLocator) { - super(serverLocator); - this.properties = properties; - } - - SpringBootHornetQConnectionFactory(HornetQProperties properties, boolean ha, - TransportConfiguration... initialConnectors) { - super(ha, initialConnectors); - this.properties = properties; - } - - @Override - public Connection createConnection() throws JMSException { - String user = this.properties.getUser(); - if (StringUtils.hasText(user)) { - return createConnection(user, this.properties.getPassword()); - } - return super.createConnection(); - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/SpringBootHornetQXAConnectionFactory.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/SpringBootHornetQXAConnectionFactory.java deleted file mode 100644 index e77cab8b2d6..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/SpringBootHornetQXAConnectionFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.jms.hornetq; - -import javax.jms.Connection; -import javax.jms.JMSException; - -import org.hornetq.api.core.TransportConfiguration; -import org.hornetq.api.core.client.ServerLocator; -import org.hornetq.jms.client.HornetQXAConnectionFactory; - -import org.springframework.util.StringUtils; - -/** - * A {@link HornetQXAConnectionFactory} that manages the credentials of the connection. - * - * @author Stéphane Lagraulet - * @author Stephane Nicoll - * @deprecated as of 1.4 in favor of the Artemis support - */ -@Deprecated -class SpringBootHornetQXAConnectionFactory extends HornetQXAConnectionFactory { - - private final HornetQProperties properties; - - SpringBootHornetQXAConnectionFactory(HornetQProperties properties, - ServerLocator serverLocator) { - super(serverLocator); - this.properties = properties; - } - - SpringBootHornetQXAConnectionFactory(HornetQProperties properties, boolean ha, - TransportConfiguration... initialConnectors) { - super(ha, initialConnectors); - this.properties = properties; - } - - @Override - public Connection createConnection() throws JMSException { - String user = this.properties.getUser(); - if (StringUtils.hasText(user)) { - return createConnection(user, this.properties.getPassword()); - } - return super.createConnection(); - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/package-info.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/package-info.java deleted file mode 100644 index 9e2b9d56e76..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/hornetq/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 HornetQ. - * @deprecated as of 1.4 in favor of the Artemis support - */ -package org.springframework.boot.autoconfigure.jms.hornetq; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfiguration.java index 9996cb2e59d..3d9bdf63ae5 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfiguration.java @@ -23,7 +23,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.jdbc.XADataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration; import org.springframework.boot.autoconfigure.jms.artemis.ArtemisAutoConfiguration; -import org.springframework.boot.autoconfigure.jms.hornetq.HornetQAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Import; @@ -35,12 +34,11 @@ import org.springframework.context.annotation.Import; * @author Phillip Webb * @since 1.2.0 */ -@SuppressWarnings("deprecation") @ConditionalOnClass(javax.transaction.Transaction.class) @ConditionalOnProperty(prefix = "spring.jta", value = "enabled", matchIfMissing = true) @AutoConfigureBefore({ XADataSourceAutoConfiguration.class, - ArtemisAutoConfiguration.class, ActiveMQAutoConfiguration.class, - HornetQAutoConfiguration.class, HibernateJpaAutoConfiguration.class }) + ActiveMQAutoConfiguration.class, ArtemisAutoConfiguration.class, + HibernateJpaAutoConfiguration.class }) @Import({ JndiJtaConfiguration.class, BitronixJtaConfiguration.class, AtomikosJtaConfiguration.class, NarayanaJtaConfiguration.class }) @EnableConfigurationProperties(JtaProperties.class) 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 62f5a8b2df2..cd9e241c6a8 100644 --- a/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories @@ -58,7 +58,6 @@ org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration,\ org.springframework.boot.autoconfigure.jms.JndiConnectionFactoryAutoConfiguration,\ org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration,\ org.springframework.boot.autoconfigure.jms.artemis.ArtemisAutoConfiguration,\ -org.springframework.boot.autoconfigure.jms.hornetq.HornetQAutoConfiguration,\ org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\ org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\ org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration,\ diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfigurationTests.java deleted file mode 100644 index 2a0795fae0a..00000000000 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQAutoConfigurationTests.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * 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.jms.hornetq; - -import java.io.File; -import java.io.IOException; -import java.util.UUID; - -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Session; -import javax.jms.TextMessage; - -import org.hornetq.api.core.TransportConfiguration; -import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory; -import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory; -import org.hornetq.jms.client.HornetQConnectionFactory; -import org.hornetq.jms.server.config.JMSConfiguration; -import org.hornetq.jms.server.config.JMSQueueConfiguration; -import org.hornetq.jms.server.config.TopicConfiguration; -import org.hornetq.jms.server.config.impl.JMSConfigurationImpl; -import org.hornetq.jms.server.config.impl.JMSQueueConfigurationImpl; -import org.hornetq.jms.server.config.impl.TopicConfigurationImpl; -import org.hornetq.jms.server.embedded.EmbeddedJMS; -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; - -import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; -import org.springframework.boot.test.util.EnvironmentTestUtils; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.jms.core.JmsTemplate; -import org.springframework.jms.core.MessageCreator; -import org.springframework.jms.core.SessionCallback; -import org.springframework.jms.support.destination.DestinationResolver; -import org.springframework.jms.support.destination.DynamicDestinationResolver; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; - -/** - * Tests for {@link HornetQAutoConfiguration}. - * - * @author Stephane Nicoll - */ -@Deprecated -@SuppressWarnings("deprecation") -public class HornetQAutoConfigurationTests { - - @Rule - public final TemporaryFolder folder = new TemporaryFolder(); - - private AnnotationConfigApplicationContext context; - - @After - public void tearDown() { - if (this.context != null) { - this.context.close(); - } - } - - @Test - public void nativeConnectionFactory() { - load(EmptyConfiguration.class, "spring.hornetq.mode:native"); - JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class); - HornetQConnectionFactory connectionFactory = this.context - .getBean(HornetQConnectionFactory.class); - assertThat(connectionFactory).isEqualTo(jmsTemplate.getConnectionFactory()); - assertNettyConnectionFactory(connectionFactory, "localhost", 5445); - } - - @Test - public void nativeConnectionFactoryCustomHost() { - load(EmptyConfiguration.class, "spring.hornetq.mode:native", - "spring.hornetq.host:192.168.1.144", "spring.hornetq.port:9876"); - HornetQConnectionFactory connectionFactory = this.context - .getBean(HornetQConnectionFactory.class); - assertNettyConnectionFactory(connectionFactory, "192.168.1.144", 9876); - } - - @Test - public void nativeConnectionFactoryCredentials() throws JMSException { - load(EmptyConfiguration.class, "spring.hornetq.mode:native", - "spring.hornetq.user:user", "spring.hornetq.password:secret"); - HornetQConnectionFactory connectionFactory = this.context - .getBean(HornetQConnectionFactory.class); - - // Validate the secured variant is invoked - HornetQConnectionFactory testCf = spy(connectionFactory); - Connection connection = mock(Connection.class); - doReturn(connection).when(testCf).createConnection("user", "secret"); - - Connection actual = testCf.createConnection(); - assertThat(actual).isSameAs(connection); - } - - @Test - public void embeddedConnectionFactory() { - load(EmptyConfiguration.class, "spring.hornetq.mode:embedded"); - - HornetQProperties properties = this.context.getBean(HornetQProperties.class); - assertThat(properties.getMode()).isEqualTo(HornetQMode.EMBEDDED); - - assertThat(this.context.getBeansOfType(EmbeddedJMS.class)).hasSize(1); - org.hornetq.core.config.Configuration configuration = this.context - .getBean(org.hornetq.core.config.Configuration.class); - assertThat(configuration.isPersistenceEnabled()).isFalse(); - assertThat(configuration.isSecurityEnabled()).isFalse(); - - HornetQConnectionFactory connectionFactory = this.context - .getBean(HornetQConnectionFactory.class); - assertInVmConnectionFactory(connectionFactory); - } - - @Test - public void embeddedConnectionFactoryByDefault() { - // No mode is specified - load(EmptyConfiguration.class); - - assertThat(this.context.getBeansOfType(EmbeddedJMS.class)).hasSize(1); - org.hornetq.core.config.Configuration configuration = this.context - .getBean(org.hornetq.core.config.Configuration.class); - assertThat(configuration.isPersistenceEnabled()).isFalse(); - assertThat(configuration.isSecurityEnabled()).isFalse(); - - HornetQConnectionFactory connectionFactory = this.context - .getBean(HornetQConnectionFactory.class); - assertInVmConnectionFactory(connectionFactory); - } - - @Test - public void nativeConnectionFactoryIfEmbeddedServiceDisabledExplicitly() { - // No mode is specified - load(EmptyConfiguration.class, "spring.hornetq.embedded.enabled:false"); - - assertThat(this.context.getBeansOfType(EmbeddedJMS.class)).isEmpty(); - - HornetQConnectionFactory connectionFactory = this.context - .getBean(HornetQConnectionFactory.class); - assertNettyConnectionFactory(connectionFactory, "localhost", 5445); - } - - @Test - public void embeddedConnectionFactoryEvenIfEmbeddedServiceDisabled() { - // No mode is specified - load(EmptyConfiguration.class, "spring.hornetq.mode:embedded", - "spring.hornetq.embedded.enabled:false"); - - assertThat(this.context.getBeansOfType(EmbeddedJMS.class)).isEmpty(); - - HornetQConnectionFactory connectionFactory = this.context - .getBean(HornetQConnectionFactory.class); - assertInVmConnectionFactory(connectionFactory); - } - - @Test - public void embeddedServerWithDestinations() { - load(EmptyConfiguration.class, "spring.hornetq.embedded.queues=Queue1,Queue2", - "spring.hornetq.embedded.topics=Topic1"); - - DestinationChecker checker = new DestinationChecker(this.context); - checker.checkQueue("Queue1", true); - checker.checkQueue("Queue2", true); - checker.checkQueue("QueueDoesNotExist", false); - - checker.checkTopic("Topic1", true); - checker.checkTopic("TopicDoesNotExist", false); - } - - @Test - public void embeddedServerWithDestinationConfig() { - load(DestinationConfiguration.class); - - DestinationChecker checker = new DestinationChecker(this.context); - checker.checkQueue("sampleQueue", true); - checker.checkTopic("sampleTopic", true); - } - - @Test - public void embeddedServiceWithCustomJmsConfiguration() { - // Ignored with custom config - load(CustomJmsConfiguration.class, - "spring.hornetq.embedded.queues=Queue1,Queue2"); - DestinationChecker checker = new DestinationChecker(this.context); - checker.checkQueue("custom", true); // See CustomJmsConfiguration - - checker.checkQueue("Queue1", false); - checker.checkQueue("Queue2", false); - } - - @Test - public void embeddedServiceWithCustomHornetQConfiguration() { - load(CustomHornetQConfiguration.class); - org.hornetq.core.config.Configuration configuration = this.context - .getBean(org.hornetq.core.config.Configuration.class); - assertThat(configuration.getName()).isEqualTo("customFooBar"); - } - - @Test - public void embeddedWithPersistentMode() throws IOException, JMSException { - File dataFolder = this.folder.newFolder(); - - // Start the server and post a message to some queue - load(EmptyConfiguration.class, "spring.hornetq.embedded.queues=TestQueue", - "spring.hornetq.embedded.persistent:true", - "spring.hornetq.embedded.dataDirectory:" + dataFolder.getAbsolutePath()); - - final String msgId = UUID.randomUUID().toString(); - JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class); - jmsTemplate.send("TestQueue", new MessageCreator() { - @Override - public Message createMessage(Session session) throws JMSException { - return session.createTextMessage(msgId); - } - }); - this.context.close(); // Shutdown the broker - - // Start the server again and check if our message is still here - load(EmptyConfiguration.class, "spring.hornetq.embedded.queues=TestQueue", - "spring.hornetq.embedded.persistent:true", - "spring.hornetq.embedded.dataDirectory:" + dataFolder.getAbsolutePath()); - - JmsTemplate jmsTemplate2 = this.context.getBean(JmsTemplate.class); - jmsTemplate2.setReceiveTimeout(1000L); - Message message = jmsTemplate2.receive("TestQueue"); - assertThat(message).isNotNull(); - assertThat(((TextMessage) message).getText()).isEqualTo(msgId); - } - - @Test - public void severalEmbeddedBrokers() { - load(EmptyConfiguration.class, "spring.hornetq.embedded.queues=Queue1"); - - AnnotationConfigApplicationContext anotherContext = doLoad( - EmptyConfiguration.class, "spring.hornetq.embedded.queues=Queue2"); - - try { - HornetQProperties properties = this.context.getBean(HornetQProperties.class); - HornetQProperties anotherProperties = anotherContext - .getBean(HornetQProperties.class); - assertThat(properties.getEmbedded().getServerId() < anotherProperties - .getEmbedded().getServerId()).isTrue(); - - DestinationChecker checker = new DestinationChecker(this.context); - checker.checkQueue("Queue1", true); - checker.checkQueue("Queue2", false); - - DestinationChecker anotherChecker = new DestinationChecker(anotherContext); - anotherChecker.checkQueue("Queue2", true); - anotherChecker.checkQueue("Queue1", false); - } - finally { - anotherContext.close(); - } - } - - @Test - public void connectToASpecificEmbeddedBroker() { - load(EmptyConfiguration.class, "spring.hornetq.embedded.serverId=93", - "spring.hornetq.embedded.queues=Queue1"); - - AnnotationConfigApplicationContext anotherContext = doLoad( - EmptyConfiguration.class, "spring.hornetq.mode=embedded", - "spring.hornetq.embedded.serverId=93", // Connect to the "main" broker - "spring.hornetq.embedded.enabled=false"); // do not start a specific one - - try { - DestinationChecker checker = new DestinationChecker(this.context); - checker.checkQueue("Queue1", true); - - DestinationChecker anotherChecker = new DestinationChecker(anotherContext); - anotherChecker.checkQueue("Queue1", true); - } - finally { - anotherContext.close(); - } - } - - private TransportConfiguration assertInVmConnectionFactory( - HornetQConnectionFactory connectionFactory) { - TransportConfiguration transportConfig = getSingleTransportConfiguration( - connectionFactory); - assertThat(transportConfig.getFactoryClassName()) - .isEqualTo(InVMConnectorFactory.class.getName()); - return transportConfig; - } - - private TransportConfiguration assertNettyConnectionFactory( - HornetQConnectionFactory connectionFactory, String host, int port) { - TransportConfiguration transportConfig = getSingleTransportConfiguration( - connectionFactory); - assertThat(transportConfig.getFactoryClassName()) - .isEqualTo(NettyConnectorFactory.class.getName()); - assertThat(transportConfig.getParams().get("host")).isEqualTo(host); - assertThat(transportConfig.getParams().get("port")).isEqualTo(port); - return transportConfig; - } - - private TransportConfiguration getSingleTransportConfiguration( - HornetQConnectionFactory connectionFactory) { - TransportConfiguration[] transportConfigurations = connectionFactory - .getServerLocator().getStaticTransportConfigurations(); - assertThat(transportConfigurations.length).isEqualTo(1); - return transportConfigurations[0]; - } - - private void load(Class config, String... environment) { - this.context = doLoad(config, environment); - } - - private AnnotationConfigApplicationContext doLoad(Class config, - String... environment) { - AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); - applicationContext.register(config); - applicationContext.register(HornetQAutoConfiguration.class, - JmsAutoConfiguration.class); - EnvironmentTestUtils.addEnvironment(applicationContext, environment); - applicationContext.refresh(); - return applicationContext; - } - - private final static class DestinationChecker { - - private final JmsTemplate jmsTemplate; - - private final DestinationResolver destinationResolver; - - private DestinationChecker(ApplicationContext applicationContext) { - this.jmsTemplate = applicationContext.getBean(JmsTemplate.class); - this.destinationResolver = new DynamicDestinationResolver(); - } - - public void checkQueue(String name, boolean shouldExist) { - checkDestination(name, false, shouldExist); - } - - public void checkTopic(String name, boolean shouldExist) { - checkDestination(name, true, shouldExist); - } - - public void checkDestination(final String name, final boolean pubSub, - final boolean shouldExist) { - this.jmsTemplate.execute(new SessionCallback() { - @Override - public Void doInJms(Session session) throws JMSException { - try { - Destination destination = DestinationChecker.this.destinationResolver - .resolveDestinationName(session, name, pubSub); - if (!shouldExist) { - throw new IllegalStateException("Destination '" + name - + "' was not expected but got " + destination); - } - } - catch (JMSException e) { - if (shouldExist) { - throw new IllegalStateException("Destination '" + name - + "' was expected but got " + e.getMessage()); - } - } - return null; - } - }); - } - } - - @Configuration - protected static class EmptyConfiguration { - } - - @Configuration - protected static class DestinationConfiguration { - - @Bean - JMSQueueConfiguration sampleQueueConfiguration() { - return new JMSQueueConfigurationImpl("sampleQueue", "foo=bar", false, - "/queue/1"); - } - - @Bean - TopicConfiguration sampleTopicConfiguration() { - return new TopicConfigurationImpl("sampleTopic", "/topic/1"); - } - } - - @Configuration - protected static class CustomJmsConfiguration { - - @Bean - public JMSConfiguration myJmsConfiguration() { - JMSConfiguration config = new JMSConfigurationImpl(); - config.getQueueConfigurations() - .add(new JMSQueueConfigurationImpl("custom", null, false)); - return config; - } - } - - @Configuration - protected static class CustomHornetQConfiguration { - - @Bean - public HornetQConfigurationCustomizer myHornetQCustomize() { - return new HornetQConfigurationCustomizer() { - @Override - public void customize( - org.hornetq.core.config.Configuration configuration) { - configuration.setClusterPassword("Foobar"); - configuration.setName("customFooBar"); - } - }; - } - } - -} diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedConfigurationFactoryTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedConfigurationFactoryTests.java deleted file mode 100644 index 5175f7dcf10..00000000000 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/hornetq/HornetQEmbeddedConfigurationFactoryTests.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.jms.hornetq; - -import org.hornetq.core.config.Configuration; -import org.hornetq.core.server.JournalType; -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link HornetQEmbeddedConfigurationFactory}. - * - * @author Stephane Nicoll - * @author Phillip Webb - */ -@Deprecated -public class HornetQEmbeddedConfigurationFactoryTests { - - @Test - public void defaultDataDir() { - HornetQProperties properties = new HornetQProperties(); - properties.getEmbedded().setPersistent(true); - Configuration configuration = new HornetQEmbeddedConfigurationFactory(properties) - .createConfiguration(); - assertThat(configuration.getJournalDirectory()) - .startsWith(System.getProperty("java.io.tmpdir")).endsWith("/journal"); - } - - @Test - public void persistenceSetup() { - HornetQProperties properties = new HornetQProperties(); - properties.getEmbedded().setPersistent(true); - Configuration configuration = new HornetQEmbeddedConfigurationFactory(properties) - .createConfiguration(); - assertThat(configuration.isPersistenceEnabled()).isTrue(); - assertThat(configuration.getJournalType()).isEqualTo(JournalType.NIO); - } - - @Test - public void generatedClusterPassword() throws Exception { - HornetQProperties properties = new HornetQProperties(); - Configuration configuration = new HornetQEmbeddedConfigurationFactory(properties) - .createConfiguration(); - assertThat(configuration.getClusterPassword().length()).isEqualTo(36); - } - - @Test - public void specificClusterPassword() throws Exception { - HornetQProperties properties = new HornetQProperties(); - properties.getEmbedded().setClusterPassword("password"); - Configuration configuration = new HornetQEmbeddedConfigurationFactory(properties) - .createConfiguration(); - assertThat(configuration.getClusterPassword()).isEqualTo("password"); - } - -} diff --git a/spring-boot-autoconfigure/src/test/resources/application.properties b/spring-boot-autoconfigure/src/test/resources/application.properties index 38b49d8506d..5a146148b6e 100644 --- a/spring-boot-autoconfigure/src/test/resources/application.properties +++ b/spring-boot-autoconfigure/src/test/resources/application.properties @@ -5,4 +5,3 @@ spring.social.twitter.appId: twid spring.social.twitter.appSecret: twsecret spring.social.linkedin.appId: liid spring.social.linkedin.appSecret: lisecret -spring.hornetq.embedded.enabled: false diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 1243b7ca06b..8a09d165de9 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -88,7 +88,6 @@ 5.2.4.Final 2.4.7 2.3.13 - 2.4.7.Final 2.3.3 2.21 4.1.2 @@ -376,11 +375,6 @@ spring-boot-starter-hateoas 1.5.0.BUILD-SNAPSHOT - - org.springframework.boot - spring-boot-starter-hornetq - 1.5.0.BUILD-SNAPSHOT - org.springframework.boot spring-boot-starter-integration @@ -1770,22 +1764,6 @@ hibernate-validator-annotation-processor ${hibernate-validator.version} - - org.hornetq - hornetq-jms-client - ${hornetq.version} - - - org.hornetq - hornetq-jms-server - ${hornetq.version} - - - org.jboss.spec.javax.transaction - jboss-transaction-api_1.1_spec - - - org.hsqldb hsqldb diff --git a/spring-boot-docs/pom.xml b/spring-boot-docs/pom.xml index 879da7e9a1a..fd753f17414 100644 --- a/spring-boot-docs/pom.xml +++ b/spring-boot-docs/pom.xml @@ -445,11 +445,6 @@ hibernate-validator true - - org.hornetq - hornetq-jms-server - true - org.infinispan infinispan-jcache diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 58d59984b86..25f2564f11f 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -854,20 +854,6 @@ content into your application; rather pick only the properties that you need. spring.batch.schema=classpath:org/springframework/batch/core/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema. spring.batch.table-prefix= # Table prefix for all the batch meta-data tables. - # HORNETQ ({sc-spring-boot-autoconfigure}/jms/hornetq/HornetQProperties.{sc-ext}[HornetQProperties]) - spring.hornetq.embedded.cluster-password= # Cluster password. Randomly generated on startup by default. - spring.hornetq.embedded.data-directory= # Journal file directory. Not necessary if persistence is turned off. - spring.hornetq.embedded.enabled=true # Enable embedded mode if the HornetQ server APIs are available. - spring.hornetq.embedded.persistent=false # Enable persistent store. - spring.hornetq.embedded.queues= # Comma-separated list of queues to create on startup. - spring.hornetq.embedded.server-id= # Server id. By default, an auto-incremented counter is used. - spring.hornetq.embedded.topics= # Comma-separated list of topics to create on startup. - spring.hornetq.host=localhost # HornetQ broker host. - spring.hornetq.mode= # HornetQ deployment mode, auto-detected by default. - spring.hornetq.password= # Login password of the broker. - spring.hornetq.port=5445 # HornetQ broker port. - spring.hornetq.user= # Login user of the broker. - # JMS ({sc-spring-boot-autoconfigure}/jms/JmsProperties.{sc-ext}[JmsProperties]) spring.jms.jndi-name= # Connection factory JNDI name. When set, takes precedence to others connection factory auto-configurations. spring.jms.listener.acknowledge-mode= # Acknowledge mode of the container. By default, the listener is transacted with automatic acknowledgment. diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index d8aa9b0a887..277393bca7e 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -4123,11 +4123,6 @@ resolved against their provided names. [[boot-features-artemis]] ==== Artemis support -Apache Artemis was formed in 2015 when HornetQ was donated to the Apache Foundation. Make -sure to use that rather than the deprecated HornetQ support. - -NOTE: You should not try and use Artemis and HornetQ at the same time. - Spring Boot can auto-configure a `ConnectionFactory` when it detects that Artemis is available on the classpath. If the broker is present, an embedded broker is started and configured automatically (unless the mode property has been explicitly set). The supported @@ -4172,55 +4167,6 @@ through configuration. -[[boot-features-hornetq]] -==== HornetQ support - -NOTE: HornetQ is deprecated in 1.4, consider migrating to <> - -Spring Boot can auto-configure a `ConnectionFactory` when it detects that HornetQ is -available on the classpath. If the broker is present, an embedded broker is started and -configured automatically (unless the mode property has been explicitly set). The supported -modes are: `embedded` (to make explicit that an embedded broker is required and should -lead to an error if the broker is not available in the classpath), and `native` to connect -to a broker using the `netty` transport protocol. When the latter is configured, Spring -Boot configures a `ConnectionFactory` connecting to a broker running on the local machine -with the default settings. - -NOTE: If you are using `spring-boot-starter-hornetq` the necessary dependencies to -connect to an existing HornetQ instance are provided, as well as the Spring infrastructure -to integrate with JMS. Adding `org.hornetq:hornetq-jms-server` to your application allows -you to use the embedded mode. - -HornetQ configuration is controlled by external configuration properties in -`+spring.hornetq.*+`. For example, you might declare the following section in -`application.properties`: - -[source,properties,indent=0] ----- - spring.hornetq.mode=native - spring.hornetq.host=192.168.1.210 - spring.hornetq.port=9876 - spring.hornetq.user=admin - spring.hornetq.password=secret ----- - -When embedding the broker, you can choose if you want to enable persistence, and the list -of destinations that should be made available. These can be specified as a comma-separated -list to create them with the default options; or you can define bean(s) of type -`org.hornetq.jms.server.config.JMSQueueConfiguration` or -`org.hornetq.jms.server.config.TopicConfiguration`, for advanced queue and topic -configurations respectively. - -See -{sc-spring-boot-autoconfigure}/jms/hornetq/HornetQProperties.{sc-ext}[`HornetQProperties`] -for more of the supported options. - -No JNDI lookup is involved at all and destinations are resolved against their names, -either using the '`name`' attribute in the HornetQ configuration or the names provided -through configuration. - - - [[boot-features-jms-jndi]] ==== Using a JNDI ConnectionFactory If you are running your application in an Application Server Spring Boot will attempt to diff --git a/spring-boot-samples/README.adoc b/spring-boot-samples/README.adoc index f5aeac729fd..c286f642f68 100644 --- a/spring-boot-samples/README.adoc +++ b/spring-boot-samples/README.adoc @@ -83,9 +83,6 @@ The following sample applications are provided: | link:spring-boot-sample-hibernate4[spring-boot-sample-hibernate52] | Demonstrates how to use Hibernate 5.2 -| link:spring-boot-sample-hornetq[spring-boot-sample-hornetq] -| Message-oriented application using HornetQ - | link:spring-boot-sample-hypermedia[spring-boot-sample-hypermedia] | Demonstrates Actuator's hypermedia support, including HAL Browser diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml index 4bfaad82642..40cb914ff93 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -47,7 +47,6 @@ spring-boot-sample-hateoas spring-boot-sample-hibernate4 spring-boot-sample-hibernate52 - spring-boot-sample-hornetq spring-boot-sample-hypermedia spring-boot-sample-hypermedia-gson spring-boot-sample-hypermedia-jpa diff --git a/spring-boot-samples/spring-boot-sample-hornetq/pom.xml b/spring-boot-samples/spring-boot-sample-hornetq/pom.xml deleted file mode 100644 index 3a2c9f7d0df..00000000000 --- a/spring-boot-samples/spring-boot-sample-hornetq/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - 4.0.0 - - - org.springframework.boot - spring-boot-samples - 1.5.0.BUILD-SNAPSHOT - - spring-boot-sample-hornetq - Spring Boot HornetQ Sample - Spring Boot HornetQ Sample - http://projects.spring.io/spring-boot/ - - Pivotal Software, Inc. - http://www.spring.io - - - ${basedir}/../.. - - - - org.springframework.boot - spring-boot-starter-hornetq - - - org.hornetq - hornetq-jms-server - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/spring-boot-samples/spring-boot-sample-hornetq/src/main/java/sample/hornetq/SampleHornetQApplication.java b/spring-boot-samples/spring-boot-sample-hornetq/src/main/java/sample/hornetq/SampleHornetQApplication.java deleted file mode 100644 index 0bce25a5016..00000000000 --- a/spring-boot-samples/spring-boot-sample-hornetq/src/main/java/sample/hornetq/SampleHornetQApplication.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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. - */ - -package sample.hornetq; - -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageListener; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.jms.listener.DefaultMessageListenerContainer; -import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor; - -@SpringBootApplication -public class SampleHornetQApplication { - - @Autowired - private ConnectionFactory connectionFactory; - - @Bean - public ScheduledAnnotationBeanPostProcessor scheduledAnnotationBeanPostProcessor() { - return new ScheduledAnnotationBeanPostProcessor(); - } - - @Bean - public DefaultMessageListenerContainer messageListener() { - DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); - container.setConnectionFactory(this.connectionFactory); - container.setDestinationName("testQueue"); - container.setMessageListener(new MessageListener() { - @Override - public void onMessage(Message message) { - try { - System.out.println(message.getBody(Object.class)); - } - catch (JMSException ex) { - ex.printStackTrace(); - } - } - }); - return container; - } - - public static void main(String[] args) throws Exception { - SpringApplication.run(SampleHornetQApplication.class, args); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-hornetq/src/main/java/sample/hornetq/Sender.java b/spring-boot-samples/spring-boot-sample-hornetq/src/main/java/sample/hornetq/Sender.java deleted file mode 100644 index 5c34c4d4c6a..00000000000 --- a/spring-boot-samples/spring-boot-sample-hornetq/src/main/java/sample/hornetq/Sender.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2012-2013 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 sample.hornetq; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jms.core.JmsTemplate; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -@Component -public class Sender { - - @Autowired - private JmsTemplate jmsTemplate; - - @Scheduled(fixedDelay = 1000L) - public void send() { - this.jmsTemplate.convertAndSend("testQueue", "Hello"); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-hornetq/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-hornetq/src/main/resources/application.properties deleted file mode 100644 index f7c09bcefd2..00000000000 --- a/spring-boot-samples/spring-boot-sample-hornetq/src/main/resources/application.properties +++ /dev/null @@ -1,3 +0,0 @@ -spring.hornetq.mode=embedded -spring.hornetq.embedded.enabled=true -spring.hornetq.embedded.queues=testQueue,anotherQueue diff --git a/spring-boot-starters/pom.xml b/spring-boot-starters/pom.xml index 9eda7150f7b..29937f00fe0 100644 --- a/spring-boot-starters/pom.xml +++ b/spring-boot-starters/pom.xml @@ -41,7 +41,6 @@ spring-boot-starter-freemarker spring-boot-starter-groovy-templates spring-boot-starter-hateoas - spring-boot-starter-hornetq spring-boot-starter-integration spring-boot-starter-jdbc spring-boot-starter-jersey diff --git a/spring-boot-starters/spring-boot-starter-hornetq/pom.xml b/spring-boot-starters/spring-boot-starter-hornetq/pom.xml deleted file mode 100644 index 8e8529e9f97..00000000000 --- a/spring-boot-starters/spring-boot-starter-hornetq/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starters - 1.5.0.BUILD-SNAPSHOT - - spring-boot-starter-hornetq - spring-boot-starter-hornetq (DEPRECATED) - Starter for JMS messaging using HornetQ. Deprecated as of 1.4 in favor - of spring-boot-starter-artemis - http://projects.spring.io/spring-boot/ - - Pivotal Software, Inc. - http://www.spring.io - - - ${basedir}/../.. - - - - org.springframework.boot - spring-boot-starter - - - org.springframework - spring-jms - - - org.hornetq - hornetq-jms-client - - - - - - org.basepom.maven - duplicate-finder-maven-plugin - - - duplicate-dependencies - validate - - check - - - - org/hornetq/utils.HornetQUtil(Bundle|Logger).i18n.properties - - - - - - - - diff --git a/spring-boot-starters/spring-boot-starter-hornetq/src/main/java/org/springframework/boot/starter/hornetq/HornetQStarterDeprecationWarningAutoConfiguration.java b/spring-boot-starters/spring-boot-starter-hornetq/src/main/java/org/springframework/boot/starter/hornetq/HornetQStarterDeprecationWarningAutoConfiguration.java deleted file mode 100644 index 88ab21a6ae6..00000000000 --- a/spring-boot-starters/spring-boot-starter-hornetq/src/main/java/org/springframework/boot/starter/hornetq/HornetQStarterDeprecationWarningAutoConfiguration.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.starter.hornetq; - -import javax.annotation.PostConstruct; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.Configuration; - -/** - * {@link EnableAutoConfiguration Auto-configuration} to print a deprecation warning about - * the starter. - * - * @author Stephane Nicoll - * @since 1.4.0 - */ -@Configuration -@Deprecated -public class HornetQStarterDeprecationWarningAutoConfiguration { - - private static final Log logger = LogFactory - .getLog(HornetQStarterDeprecationWarningAutoConfiguration.class); - - @PostConstruct - public void logWarning() { - logger.warn("spring-boot-starter-hornetq is deprecated as of Spring Boot 1.4, " - + "please migrate to spring-boot-starter-artemis"); - } - -} diff --git a/spring-boot-starters/spring-boot-starter-hornetq/src/main/resources/META-INF/spring.factories b/spring-boot-starters/spring-boot-starter-hornetq/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 989f05e7b02..00000000000 --- a/spring-boot-starters/spring-boot-starter-hornetq/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Auto Configure -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.springframework.boot.starter.hornetq.HornetQStarterDeprecationWarningAutoConfiguration diff --git a/spring-boot-starters/spring-boot-starter-hornetq/src/main/resources/META-INF/spring.provides b/spring-boot-starters/spring-boot-starter-hornetq/src/main/resources/META-INF/spring.provides deleted file mode 100644 index 09425bb7c86..00000000000 --- a/spring-boot-starters/spring-boot-starter-hornetq/src/main/resources/META-INF/spring.provides +++ /dev/null @@ -1 +0,0 @@ -provides: hornetq-jms-client,spring-jms \ No newline at end of file From 2a035d074899fe75ff64e9d0ece7116f2cd51d38 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 29 Sep 2016 14:05:49 +0100 Subject: [PATCH 2/2] Remove support for Velocity following its deprecation in 1.4 Closes gh-6971 --- spring-boot-autoconfigure/pom.xml | 5 - .../velocity/VelocityAutoConfiguration.java | 165 ------------ .../velocity/VelocityProperties.java | 138 ---------- .../VelocityTemplateAvailabilityProvider.java | 57 ---- .../autoconfigure/velocity/package-info.java | 22 -- .../main/resources/META-INF/spring.factories | 2 - ...eAutoConfigurationImportSelectorTests.java | 19 +- .../VelocityAutoConfigurationTests.java | 246 ------------------ ...cityTemplateAvailabilityProviderTests.java | 75 ------ spring-boot-dependencies/pom.xml | 23 -- ...DevToolsPropertyDefaultsPostProcessor.java | 1 - spring-boot-docs/pom.xml | 10 - .../appendix-application-properties.adoc | 22 -- spring-boot-docs/src/main/asciidoc/howto.adoc | 42 +-- .../main/asciidoc/spring-boot-features.adoc | 10 +- spring-boot-samples/README.adoc | 6 - spring-boot-samples/pom.xml | 2 - .../spring-boot-sample-velocity/pom.xml | 56 ---- .../velocity/SampleVelocityApplication.java | 55 ---- .../src/main/resources/application.properties | 1 - .../src/main/resources/templates/welcome.vm | 2 - .../SampleVelocityApplicationTests.java | 47 ---- .../spring-boot-sample-web-velocity/pom.xml | 48 ---- .../SampleWebVelocityApplication.java | 29 --- .../web/velocity/WelcomeController.java | 39 --- .../src/main/resources/application.properties | 2 - .../src/main/resources/templates/error.vm | 9 - .../src/main/resources/templates/welcome.vm | 14 - .../SampleWebVelocityApplicationTests.java | 74 ------ spring-boot-starters/pom.xml | 1 - .../spring-boot-starter-velocity/pom.xml | 55 ---- spring-boot/pom.xml | 10 - .../velocity/EmbeddedVelocityToolboxView.java | 113 -------- .../EmbeddedVelocityViewResolver.java | 55 ---- .../servlet/view/velocity/package-info.java | 20 -- .../EmbeddedVelocityToolboxViewTests.java | 95 ------- .../EmbeddedVelocityViewResolverTests.java | 98 ------- .../web/servlet/view/velocity/toolbox.xml | 8 - 38 files changed, 15 insertions(+), 1661 deletions(-) delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityProperties.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProvider.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/package-info.java delete mode 100644 spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfigurationTests.java delete mode 100644 spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProviderTests.java delete mode 100644 spring-boot-samples/spring-boot-sample-velocity/pom.xml delete mode 100644 spring-boot-samples/spring-boot-sample-velocity/src/main/java/sample/velocity/SampleVelocityApplication.java delete mode 100644 spring-boot-samples/spring-boot-sample-velocity/src/main/resources/application.properties delete mode 100644 spring-boot-samples/spring-boot-sample-velocity/src/main/resources/templates/welcome.vm delete mode 100644 spring-boot-samples/spring-boot-sample-velocity/src/test/java/sample/velocity/SampleVelocityApplicationTests.java delete mode 100644 spring-boot-samples/spring-boot-sample-web-velocity/pom.xml delete mode 100644 spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/SampleWebVelocityApplication.java delete mode 100644 spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/WelcomeController.java delete mode 100644 spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/application.properties delete mode 100644 spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/templates/error.vm delete mode 100644 spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/templates/welcome.vm delete mode 100644 spring-boot-samples/spring-boot-sample-web-velocity/src/test/java/sample/web/velocity/SampleWebVelocityApplicationTests.java delete mode 100644 spring-boot-starters/spring-boot-starter-velocity/pom.xml delete mode 100644 spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityToolboxView.java delete mode 100644 spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityViewResolver.java delete mode 100644 spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/package-info.java delete mode 100644 spring-boot/src/test/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityToolboxViewTests.java delete mode 100644 spring-boot/src/test/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityViewResolverTests.java delete mode 100644 spring-boot/src/test/resources/org/springframework/boot/web/servlet/view/velocity/toolbox.xml diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml index a3ff5fdb70e..fd311054d86 100755 --- a/spring-boot-autoconfigure/pom.xml +++ b/spring-boot-autoconfigure/pom.xml @@ -205,11 +205,6 @@ tomcat-jdbc true - - org.apache.velocity - velocity - true - org.codehaus.btm btm diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration.java deleted file mode 100644 index 6e3497134a6..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfiguration.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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.velocity; - -import java.io.IOException; -import java.util.Properties; - -import javax.annotation.PostConstruct; -import javax.servlet.Servlet; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.velocity.app.VelocityEngine; -import org.apache.velocity.exception.VelocityException; - -import org.springframework.beans.factory.annotation.Autowired; -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.boot.autoconfigure.condition.ConditionalOnNotWebApplication; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.boot.autoconfigure.template.TemplateLocation; -import org.springframework.boot.autoconfigure.web.ConditionalOnEnabledResourceChain; -import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.web.servlet.view.velocity.EmbeddedVelocityViewResolver; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.ui.velocity.VelocityEngineFactory; -import org.springframework.ui.velocity.VelocityEngineFactoryBean; -import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter; -import org.springframework.web.servlet.view.velocity.VelocityConfig; -import org.springframework.web.servlet.view.velocity.VelocityConfigurer; - -/** - * {@link EnableAutoConfiguration Auto-configuration} for Velocity. - * - * @author Andy Wilkinson - * @author Brian Clozel - * @since 1.1.0 - * @deprecated as of 1.4 following the deprecation of Velocity support in Spring Framework - * 4.3 - */ -@Configuration -@ConditionalOnClass({ VelocityEngine.class, VelocityEngineFactory.class }) -@AutoConfigureAfter(WebMvcAutoConfiguration.class) -@EnableConfigurationProperties(VelocityProperties.class) -@Deprecated -public class VelocityAutoConfiguration { - - private static final Log logger = LogFactory.getLog(VelocityAutoConfiguration.class); - - private final ApplicationContext applicationContext; - - private final VelocityProperties properties; - - public VelocityAutoConfiguration(ApplicationContext applicationContext, - VelocityProperties properties) { - this.applicationContext = applicationContext; - this.properties = properties; - } - - @PostConstruct - public void checkTemplateLocationExists() { - if (this.properties.isCheckTemplateLocation()) { - TemplateLocation location = new TemplateLocation( - this.properties.getResourceLoaderPath()); - if (!location.exists(this.applicationContext)) { - logger.warn("Cannot find template location: " + location - + " (please add some templates, check your Velocity " - + "configuration, or set spring.velocity." - + "checkTemplateLocation=false)"); - } - } - } - - @Deprecated - protected static class VelocityConfiguration { - - @Autowired - protected VelocityProperties properties; - - protected void applyProperties(VelocityEngineFactory factory) { - factory.setResourceLoaderPath(this.properties.getResourceLoaderPath()); - factory.setPreferFileSystemAccess(this.properties.isPreferFileSystemAccess()); - Properties velocityProperties = new Properties(); - velocityProperties.setProperty("input.encoding", - this.properties.getCharsetName()); - velocityProperties.putAll(this.properties.getProperties()); - factory.setVelocityProperties(velocityProperties); - } - - } - - @Configuration - @ConditionalOnNotWebApplication - @Deprecated - public static class VelocityNonWebConfiguration extends VelocityConfiguration { - - @Bean - @ConditionalOnMissingBean - public VelocityEngineFactoryBean velocityConfiguration() { - VelocityEngineFactoryBean velocityEngineFactoryBean = new VelocityEngineFactoryBean(); - applyProperties(velocityEngineFactoryBean); - return velocityEngineFactoryBean; - } - - } - - @Configuration - @ConditionalOnClass(Servlet.class) - @ConditionalOnWebApplication - @Deprecated - public static class VelocityWebConfiguration extends VelocityConfiguration { - - @Bean - @ConditionalOnMissingBean(VelocityConfig.class) - public VelocityConfigurer velocityConfigurer() { - VelocityConfigurer configurer = new VelocityConfigurer(); - applyProperties(configurer); - return configurer; - } - - @Bean - public VelocityEngine velocityEngine(VelocityConfigurer configurer) - throws VelocityException, IOException { - return configurer.getVelocityEngine(); - } - - @Bean - @ConditionalOnMissingBean(name = "velocityViewResolver") - @ConditionalOnProperty(name = "spring.velocity.enabled", matchIfMissing = true) - public EmbeddedVelocityViewResolver velocityViewResolver() { - EmbeddedVelocityViewResolver resolver = new EmbeddedVelocityViewResolver(); - this.properties.applyToViewResolver(resolver); - return resolver; - } - - @Bean - @ConditionalOnMissingBean - @ConditionalOnEnabledResourceChain - public ResourceUrlEncodingFilter resourceUrlEncodingFilter() { - return new ResourceUrlEncodingFilter(); - } - - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityProperties.java deleted file mode 100644 index c01878421dc..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityProperties.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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.velocity; - -import java.util.HashMap; -import java.util.Map; - -import org.springframework.boot.autoconfigure.template.AbstractTemplateViewResolverProperties; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.web.servlet.view.velocity.VelocityViewResolver; - -/** - * {@link ConfigurationProperties} for configuring Velocity. - * - * @author Andy Wilkinson - * @since 1.1.0 - * @deprecated as of 1.4 following the deprecation of Velocity support in Spring Framework - * 4.3 - */ -@Deprecated -@ConfigurationProperties(prefix = "spring.velocity") -public class VelocityProperties extends AbstractTemplateViewResolverProperties { - - public static final String DEFAULT_RESOURCE_LOADER_PATH = "classpath:/templates/"; - - public static final String DEFAULT_PREFIX = ""; - - public static final String DEFAULT_SUFFIX = ".vm"; - - /** - * Name of the DateTool helper object to expose in the Velocity context of the view. - */ - private String dateToolAttribute; - - /** - * Name of the NumberTool helper object to expose in the Velocity context of the view. - */ - private String numberToolAttribute; - - /** - * Additional velocity properties. - */ - private Map properties = new HashMap(); - - /** - * Template path. - */ - private String resourceLoaderPath = DEFAULT_RESOURCE_LOADER_PATH; - - /** - * Velocity Toolbox config location, for example "/WEB-INF/toolbox.xml". Automatically - * loads a Velocity Tools toolbox definition file and expose all defined tools in the - * specified scopes. - */ - private String toolboxConfigLocation; - - /** - * Prefer file system access for template loading. File system access enables hot - * detection of template changes. - */ - private boolean preferFileSystemAccess = true; - - public VelocityProperties() { - super(DEFAULT_PREFIX, DEFAULT_SUFFIX); - } - - public String getDateToolAttribute() { - return this.dateToolAttribute; - } - - public void setDateToolAttribute(String dateToolAttribute) { - this.dateToolAttribute = dateToolAttribute; - } - - public String getNumberToolAttribute() { - return this.numberToolAttribute; - } - - public void setNumberToolAttribute(String numberToolAttribute) { - this.numberToolAttribute = numberToolAttribute; - } - - public Map getProperties() { - return this.properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - - public String getResourceLoaderPath() { - return this.resourceLoaderPath; - } - - public void setResourceLoaderPath(String resourceLoaderPath) { - this.resourceLoaderPath = resourceLoaderPath; - } - - public String getToolboxConfigLocation() { - return this.toolboxConfigLocation; - } - - public void setToolboxConfigLocation(String toolboxConfigLocation) { - this.toolboxConfigLocation = toolboxConfigLocation; - } - - public boolean isPreferFileSystemAccess() { - return this.preferFileSystemAccess; - } - - public void setPreferFileSystemAccess(boolean preferFileSystemAccess) { - this.preferFileSystemAccess = preferFileSystemAccess; - } - - @Override - public void applyToViewResolver(Object viewResolver) { - super.applyToViewResolver(viewResolver); - VelocityViewResolver resolver = (VelocityViewResolver) viewResolver; - resolver.setToolboxConfigLocation(getToolboxConfigLocation()); - resolver.setDateToolAttribute(getDateToolAttribute()); - resolver.setNumberToolAttribute(getNumberToolAttribute()); - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProvider.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProvider.java deleted file mode 100644 index 1dd17912137..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProvider.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.velocity; - -import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider; -import org.springframework.boot.bind.RelaxedPropertyResolver; -import org.springframework.core.env.Environment; -import org.springframework.core.env.PropertyResolver; -import org.springframework.core.io.ResourceLoader; -import org.springframework.util.ClassUtils; - -/** - * {@link TemplateAvailabilityProvider} that provides availability information for - * Velocity view templates. - * - * @author Andy Wilkinson - * @since 1.1.0 - * @deprecated as of 1.4 following the deprecation of Velocity support in Spring Framework - * 4.3 - */ -@Deprecated -public class VelocityTemplateAvailabilityProvider - implements TemplateAvailabilityProvider { - - @Override - public boolean isTemplateAvailable(String view, Environment environment, - ClassLoader classLoader, ResourceLoader resourceLoader) { - if (ClassUtils.isPresent("org.apache.velocity.app.VelocityEngine", classLoader)) { - PropertyResolver resolver = new RelaxedPropertyResolver(environment, - "spring.velocity."); - String loaderPath = resolver.getProperty("resource-loader-path", - VelocityProperties.DEFAULT_RESOURCE_LOADER_PATH); - String prefix = resolver.getProperty("prefix", - VelocityProperties.DEFAULT_PREFIX); - String suffix = resolver.getProperty("suffix", - VelocityProperties.DEFAULT_SUFFIX); - return resourceLoader.getResource(loaderPath + prefix + view + suffix) - .exists(); - } - return false; - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/package-info.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/package-info.java deleted file mode 100644 index 571f4799d4f..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/velocity/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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 Velocity. - * @deprecated as of 1.4 following the deprecation of Velocity support in Spring Framework - * 4.3 - */ -package org.springframework.boot.autoconfigure.velocity; 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 cd9e241c6a8..03e96c9a9a9 100644 --- a/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories @@ -84,7 +84,6 @@ org.springframework.boot.autoconfigure.social.FacebookAutoConfiguration,\ org.springframework.boot.autoconfigure.social.LinkedInAutoConfiguration,\ org.springframework.boot.autoconfigure.social.TwitterAutoConfiguration,\ org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration,\ -org.springframework.boot.autoconfigure.velocity.VelocityAutoConfiguration,\ org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\ org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,\ org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\ @@ -113,5 +112,4 @@ org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemplateAvailability org.springframework.boot.autoconfigure.mustache.MustacheTemplateAvailabilityProvider,\ org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAvailabilityProvider,\ org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemplateAvailabilityProvider,\ -org.springframework.boot.autoconfigure.velocity.VelocityTemplateAvailabilityProvider,\ org.springframework.boot.autoconfigure.web.JspTemplateAvailabilityProvider diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java index 2642cc0cd11..306b132ac9c 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelectorTests.java @@ -27,8 +27,8 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport; import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration; +import org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration; import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; -import org.springframework.boot.autoconfigure.velocity.VelocityAutoConfiguration; import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.support.SpringFactoriesLoader; @@ -46,7 +46,6 @@ import static org.mockito.BDDMockito.given; * @author Stephane Nicoll * */ -@SuppressWarnings("deprecation") public class EnableAutoConfigurationImportSelectorTests { private final EnableAutoConfigurationImportSelector importSelector = new EnableAutoConfigurationImportSelector(); @@ -92,12 +91,12 @@ public class EnableAutoConfigurationImportSelectorTests { @Test public void classNamesExclusionsAreApplied() { configureExclusions(new String[0], - new String[] { VelocityAutoConfiguration.class.getName() }, + new String[] { MustacheAutoConfiguration.class.getName() }, new String[0]); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 1); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions()) - .contains(VelocityAutoConfiguration.class.getName()); + .contains(MustacheAutoConfiguration.class.getName()); } @Test @@ -114,12 +113,12 @@ public class EnableAutoConfigurationImportSelectorTests { public void severalPropertyExclusionsAreApplied() { configureExclusions(new String[0], new String[0], new String[] { FreeMarkerAutoConfiguration.class.getName(), - VelocityAutoConfiguration.class.getName() }); + MustacheAutoConfiguration.class.getName() }); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 2); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions()) .contains(FreeMarkerAutoConfiguration.class.getName(), - VelocityAutoConfiguration.class.getName()); + MustacheAutoConfiguration.class.getName()); } @Test @@ -128,24 +127,24 @@ public class EnableAutoConfigurationImportSelectorTests { this.environment.setProperty("spring.autoconfigure.exclude[0]", FreeMarkerAutoConfiguration.class.getName()); this.environment.setProperty("spring.autoconfigure.exclude[1]", - VelocityAutoConfiguration.class.getName()); + MustacheAutoConfiguration.class.getName()); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 2); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions()) .contains(FreeMarkerAutoConfiguration.class.getName(), - VelocityAutoConfiguration.class.getName()); + MustacheAutoConfiguration.class.getName()); } @Test public void combinedExclusionsAreApplied() { - configureExclusions(new String[] { VelocityAutoConfiguration.class.getName() }, + configureExclusions(new String[] { MustacheAutoConfiguration.class.getName() }, new String[] { FreeMarkerAutoConfiguration.class.getName() }, new String[] { ThymeleafAutoConfiguration.class.getName() }); String[] imports = this.importSelector.selectImports(this.annotationMetadata); assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 3); assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions()) .contains(FreeMarkerAutoConfiguration.class.getName(), - VelocityAutoConfiguration.class.getName(), + MustacheAutoConfiguration.class.getName(), ThymeleafAutoConfiguration.class.getName()); } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfigurationTests.java deleted file mode 100644 index c5ddf074b82..00000000000 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityAutoConfigurationTests.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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.velocity; - -import java.io.File; -import java.io.StringWriter; -import java.util.Locale; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.VelocityEngine; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import org.springframework.boot.test.rule.OutputCapture; -import org.springframework.boot.test.util.EnvironmentTestUtils; -import org.springframework.boot.web.servlet.view.velocity.EmbeddedVelocityViewResolver; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.mock.web.MockServletContext; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.servlet.View; -import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter; -import org.springframework.web.servlet.support.RequestContext; -import org.springframework.web.servlet.view.AbstractTemplateViewResolver; -import org.springframework.web.servlet.view.velocity.VelocityConfigurer; -import org.springframework.web.servlet.view.velocity.VelocityViewResolver; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.containsString; - -/** - * Tests for {@link VelocityAutoConfiguration}. - * - * @author Andy Wilkinson - * @author Stephane Nicoll - */ -@SuppressWarnings("deprecation") -public class VelocityAutoConfigurationTests { - - @Rule - public OutputCapture output = new OutputCapture(); - - private AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); - - @Before - public void setupContext() { - this.context.setServletContext(new MockServletContext()); - } - - @After - public void close() { - if (this.context != null) { - this.context.close(); - } - } - - @Test - public void defaultConfiguration() { - registerAndRefreshContext(); - assertThat(this.context.getBean(VelocityViewResolver.class)).isNotNull(); - assertThat(this.context.getBean(VelocityConfigurer.class)).isNotNull(); - } - - @Test - public void nonExistentTemplateLocation() { - registerAndRefreshContext( - "spring.velocity.resourceLoaderPath:" + "classpath:/does-not-exist/"); - this.output.expect(containsString("Cannot find template location")); - } - - @Test - public void emptyTemplateLocation() { - new File("target/test-classes/templates/empty-directory").mkdir(); - registerAndRefreshContext("spring.velocity.resourceLoaderPath:" - + "classpath:/templates/empty-directory/"); - } - - @Test - public void defaultViewResolution() throws Exception { - registerAndRefreshContext(); - MockHttpServletResponse response = render("home"); - String result = response.getContentAsString(); - assertThat(result).contains("home"); - assertThat(response.getContentType()).isEqualTo("text/html;charset=UTF-8"); - } - - @Test - public void customContentType() throws Exception { - registerAndRefreshContext("spring.velocity.contentType:application/json"); - MockHttpServletResponse response = render("home"); - String result = response.getContentAsString(); - assertThat(result).contains("home"); - assertThat(response.getContentType()).isEqualTo("application/json;charset=UTF-8"); - } - - @Test - public void customCharset() throws Exception { - registerAndRefreshContext("spring.velocity.charset:ISO-8859-1"); - assertThat(this.context.getBean(VelocityConfigurer.class).getVelocityEngine() - .getProperty("input.encoding")).isEqualTo("ISO-8859-1"); - } - - @Test - public void customPrefix() throws Exception { - registerAndRefreshContext("spring.velocity.prefix:prefix/"); - MockHttpServletResponse response = render("prefixed"); - String result = response.getContentAsString(); - assertThat(result).contains("prefixed"); - } - - @Test - public void customSuffix() throws Exception { - registerAndRefreshContext("spring.velocity.suffix:.freemarker"); - MockHttpServletResponse response = render("suffixed"); - String result = response.getContentAsString(); - assertThat(result).contains("suffixed"); - } - - @Test - public void customTemplateLoaderPath() throws Exception { - registerAndRefreshContext( - "spring.velocity.resourceLoaderPath:classpath:/custom-templates/"); - MockHttpServletResponse response = render("custom"); - String result = response.getContentAsString(); - assertThat(result).contains("custom"); - } - - @Test - public void disableCache() { - registerAndRefreshContext("spring.velocity.cache:false"); - assertThat(this.context.getBean(VelocityViewResolver.class).getCacheLimit()) - .isEqualTo(0); - } - - @Test - public void customVelocitySettings() { - registerAndRefreshContext( - "spring.velocity.properties.directive.parse.max.depth:10"); - assertThat(this.context.getBean(VelocityConfigurer.class).getVelocityEngine() - .getProperty("directive.parse.max.depth")).isEqualTo("10"); - } - - @Test - public void renderTemplate() throws Exception { - registerAndRefreshContext(); - VelocityConfigurer velocity = this.context.getBean(VelocityConfigurer.class); - StringWriter writer = new StringWriter(); - Template template = velocity.getVelocityEngine().getTemplate("message.vm"); - template.process(); - VelocityContext velocityContext = new VelocityContext(); - velocityContext.put("greeting", "Hello World"); - template.merge(velocityContext, writer); - assertThat(writer.toString()).contains("Hello World"); - } - - @Test - public void renderNonWebAppTemplate() throws Exception { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( - VelocityAutoConfiguration.class); - try { - VelocityEngine velocity = context.getBean(VelocityEngine.class); - StringWriter writer = new StringWriter(); - Template template = velocity.getTemplate("message.vm"); - template.process(); - VelocityContext velocityContext = new VelocityContext(); - velocityContext.put("greeting", "Hello World"); - template.merge(velocityContext, writer); - assertThat(writer.toString()).contains("Hello World"); - } - finally { - context.close(); - } - } - - @Test - public void usesEmbeddedVelocityViewResolver() { - registerAndRefreshContext("spring.velocity.toolbox:/toolbox.xml"); - VelocityViewResolver resolver = this.context.getBean(VelocityViewResolver.class); - assertThat(resolver).isInstanceOf(EmbeddedVelocityViewResolver.class); - } - - @Test - public void registerResourceHandlingFilterDisabledByDefault() throws Exception { - registerAndRefreshContext(); - assertThat(this.context.getBeansOfType(ResourceUrlEncodingFilter.class)) - .isEmpty(); - } - - @Test - public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() - throws Exception { - registerAndRefreshContext("spring.resources.chain.enabled:true"); - assertThat(this.context.getBean(ResourceUrlEncodingFilter.class)).isNotNull(); - } - - @Test - public void allowSessionOverride() { - registerAndRefreshContext("spring.velocity.allow-session-override:true"); - AbstractTemplateViewResolver viewResolver = this.context - .getBean(VelocityViewResolver.class); - assertThat(viewResolver).extracting("allowSessionOverride").containsExactly(true); - } - - private void registerAndRefreshContext(String... env) { - EnvironmentTestUtils.addEnvironment(this.context, env); - this.context.register(VelocityAutoConfiguration.class); - this.context.refresh(); - } - - public String getGreeting() { - return "Hello World"; - } - - private MockHttpServletResponse render(String viewName) throws Exception { - VelocityViewResolver resolver = this.context.getBean(VelocityViewResolver.class); - View view = resolver.resolveViewName(viewName, Locale.UK); - assertThat(view).isNotNull(); - HttpServletRequest request = new MockHttpServletRequest(); - request.setAttribute(RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE, - this.context); - MockHttpServletResponse response = new MockHttpServletResponse(); - view.render(null, request, response); - return response; - } - -} diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProviderTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProviderTests.java deleted file mode 100644 index 870729f9156..00000000000 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/velocity/VelocityTemplateAvailabilityProviderTests.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.velocity; - -import org.junit.Test; - -import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.io.ResourceLoader; -import org.springframework.mock.env.MockEnvironment; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link VelocityTemplateAvailabilityProvider}. - * - * @author Andy Wilkinson - */ -@SuppressWarnings("deprecation") -public class VelocityTemplateAvailabilityProviderTests { - - private final TemplateAvailabilityProvider provider = new VelocityTemplateAvailabilityProvider(); - - private final ResourceLoader resourceLoader = new DefaultResourceLoader(); - - private final MockEnvironment environment = new MockEnvironment(); - - @Test - public void availabilityOfTemplateInDefaultLocation() { - assertThat(this.provider.isTemplateAvailable("home", this.environment, - getClass().getClassLoader(), this.resourceLoader)).isTrue(); - } - - @Test - public void availabilityOfTemplateThatDoesNotExist() { - assertThat(this.provider.isTemplateAvailable("whatever", this.environment, - getClass().getClassLoader(), this.resourceLoader)).isFalse(); - } - - @Test - public void availabilityOfTemplateWithCustomLoaderPath() { - this.environment.setProperty("spring.velocity.resourceLoaderPath", - "classpath:/custom-templates/"); - assertThat(this.provider.isTemplateAvailable("custom", this.environment, - getClass().getClassLoader(), this.resourceLoader)).isTrue(); - } - - @Test - public void availabilityOfTemplateWithCustomPrefix() { - this.environment.setProperty("spring.velocity.prefix", "prefix/"); - assertThat(this.provider.isTemplateAvailable("prefixed", this.environment, - getClass().getClassLoader(), this.resourceLoader)).isTrue(); - } - - @Test - public void availabilityOfTemplateWithCustomSuffix() { - this.environment.setProperty("spring.velocity.suffix", ".freemarker"); - assertThat(this.provider.isTemplateAvailable("suffixed", this.environment, - getClass().getClassLoader(), this.resourceLoader)).isTrue(); - } -} diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 8a09d165de9..0d66b628815 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -179,8 +179,6 @@ 2.1.0.RELEASE 8.5.5 1.4.3.Final - 1.7 - 2.0 9f96c74 0.32 1.6.3 @@ -496,11 +494,6 @@ spring-boot-starter-validation 1.5.0.BUILD-SNAPSHOT - - org.springframework.boot - spring-boot-starter-velocity - 1.5.0.BUILD-SNAPSHOT - org.springframework.boot spring-boot-starter-web @@ -1336,22 +1329,6 @@ tomcat-jsp-api ${tomcat.version} - - org.apache.velocity - velocity - ${velocity.version} - - - org.apache.velocity - velocity-tools - ${velocity-tools.version} - - - commons-logging - commons-logging - - - org.aspectj aspectjrt diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java index c3814a03fe6..8f31f4f8749 100755 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java @@ -46,7 +46,6 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro properties.put("spring.thymeleaf.cache", "false"); properties.put("spring.freemarker.cache", "false"); properties.put("spring.groovy.template.cache", "false"); - properties.put("spring.velocity.cache", "false"); properties.put("spring.mustache.cache", "false"); properties.put("server.session.persistent", "true"); properties.put("spring.h2.console.enabled", "true"); diff --git a/spring-boot-docs/pom.xml b/spring-boot-docs/pom.xml index fd753f17414..00c64be0bd3 100644 --- a/spring-boot-docs/pom.xml +++ b/spring-boot-docs/pom.xml @@ -304,16 +304,6 @@ tomcat-jdbc true - - org.apache.velocity - velocity - true - - - org.apache.velocity - velocity-tools - true - org.assertj assertj-core diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 25f2564f11f..27cae660c0d 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -407,28 +407,6 @@ content into your application; rather pick only the properties that you need. spring.thymeleaf.template-resolver-order= # Order of the template resolver in the chain. spring.thymeleaf.view-names= # Comma-separated list of view names that can be resolved. - # VELOCITY TEMPLATES ({sc-spring-boot-autoconfigure}/velocity/VelocityAutoConfiguration.{sc-ext}[VelocityAutoConfiguration]) - spring.velocity.allow-request-override=false # Set whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name. - spring.velocity.allow-session-override=false # Set whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name. - spring.velocity.cache= # Enable template caching. - spring.velocity.charset=UTF-8 # Template encoding. - spring.velocity.check-template-location=true # Check that the templates location exists. - spring.velocity.content-type=text/html # Content-Type value. - spring.velocity.date-tool-attribute= # Name of the DateTool helper object to expose in the Velocity context of the view. - spring.velocity.enabled=true # Enable MVC view resolution for this technology. - spring.velocity.expose-request-attributes=false # Set whether all request attributes should be added to the model prior to merging with the template. - spring.velocity.expose-session-attributes=false # Set whether all HttpSession attributes should be added to the model prior to merging with the template. - spring.velocity.expose-spring-macro-helpers=true # Set whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext". - spring.velocity.number-tool-attribute= # Name of the NumberTool helper object to expose in the Velocity context of the view. - spring.velocity.prefer-file-system-access=true # Prefer file system access for template loading. File system access enables hot detection of template changes. - spring.velocity.prefix= # Prefix that gets prepended to view names when building a URL. - spring.velocity.properties.*= # Additional velocity properties. - spring.velocity.request-context-attribute= # Name of the RequestContext attribute for all views. - spring.velocity.resource-loader-path=classpath:/templates/ # Template path. - spring.velocity.suffix=.vm # Suffix that gets appended to view names when building a URL. - spring.velocity.toolbox-config-location= # Velocity Toolbox config location. For instance `/WEB-INF/toolbox.xml` - spring.velocity.view-names= # White list of view names that can be resolved. - # SPRING WEB SERVICES ({sc-spring-boot-autoconfigure}/webservices/WebServicesProperties.{sc-ext}[WebServicesProperties]) spring.webservices.path=/services # Path that serves as the base URI for the services. spring.webservices.servlet.init= # Servlet init parameters to pass to Spring Web Services. diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index 844a75abba7..3480429738d 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -1417,41 +1417,11 @@ added. suffix (externalized to `spring.groovy.template.prefix` and `spring.groovy.template.suffix`, defaults '`classpath:/templates/`' and '`.tpl`' respectively). It can be overridden by providing a bean of the same name. -* If you use Velocity you will also have a `VelocityViewResolver` with id '`velocityViewResolver`'. - It looks for resources in a loader path (externalized to `spring.velocity.resourceLoaderPath`, - default '`classpath:/templates/`') by surrounding the view name with a prefix and suffix - (externalized to `spring.velocity.prefix` and `spring.velocity.suffix`, with empty and '`.vm`' - defaults respectively). It can be overridden by providing a bean of the same name. Check out {sc-spring-boot-autoconfigure}/web/WebMvcAutoConfiguration.{sc-ext}[`WebMvcAutoConfiguration`], {sc-spring-boot-autoconfigure}/thymeleaf/ThymeleafAutoConfiguration.{sc-ext}[`ThymeleafAutoConfiguration`], -{sc-spring-boot-autoconfigure}/freemarker/FreeMarkerAutoConfiguration.{sc-ext}[`FreeMarkerAutoConfiguration`], -{sc-spring-boot-autoconfigure}/groovy/template/GroovyTemplateAutoConfiguration.{sc-ext}[`GroovyTemplateAutoConfiguration`] and -{sc-spring-boot-autoconfigure}/velocity/VelocityAutoConfiguration.{sc-ext}[`VelocityAutoConfiguration`] - - - -[[howto-customize-view-resolvers-velocity]] -=== Velocity -By default, Spring Boot configures a `VelocityViewResolver`. If you need a -`VelocityLayoutViewResolver` instead, you can easily configure your own by creating a bean -with name `velocityViewResolver`. You can also inject the `VelocityProperties` instance to -apply the base defaults to your custom view resolver. - -The following example replaces the auto-configured velocity view resolver with a -`VelocityLayoutViewResolver` defining a customized `layoutUrl` and all settings that would -have been applied from the auto-configuration: - -[source,java,indent=0,subs="verbatim,quotes,attributes"] ----- - @Bean(name = "velocityViewResolver") - public VelocityLayoutViewResolver velocityViewResolver(VelocityProperties properties) { - VelocityLayoutViewResolver resolver = new VelocityLayoutViewResolver(); - properties.applyToViewResolver(resolver); - resolver.setLayoutUrl("layout/default.vm"); - return resolver; - } ----- +{sc-spring-boot-autoconfigure}/freemarker/FreeMarkerAutoConfiguration.{sc-ext}[`FreeMarkerAutoConfiguration`] and +{sc-spring-boot-autoconfigure}/groovy/template/GroovyTemplateAutoConfiguration.{sc-ext}[`GroovyTemplateAutoConfiguration`] @@ -2370,14 +2340,6 @@ for other Groovy customization options. -[[howto-reload-velocity-content]] -==== Velocity templates -If you are using Velocity, then set `spring.velocity.cache` to `false`. See -{sc-spring-boot-autoconfigure}/velocity/VelocityAutoConfiguration.{sc-ext}[`VelocityAutoConfiguration`] -for other Velocity customization options. - - - [[howto-reload-fast-restart]] === Fast application restarts The `spring-boot-devtools` module includes support for automatic application restarts. diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 277393bca7e..7c31717d64b 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -1774,10 +1774,9 @@ solution for all static resources, effectively adding a content hash in URLs, su ---- NOTE: Links to resources are rewritten at runtime in template, thanks to a -`ResourceUrlEncodingFilter`, auto-configured for Thymeleaf, Velocity and FreeMarker. You -should manually declare this filter when using JSPs. Other template engines aren't -automatically supported right now, but can be with custom template macros/helpers and the -use of the +`ResourceUrlEncodingFilter`, auto-configured for Thymeleaf and FreeMarker. You should +manually declare this filter when using JSPs. Other template engines aren't automatically +supported right now, but can be with custom template macros/helpers and the use of the {spring-javadoc}/web/servlet/resource/ResourceUrlProvider.{dc-ext}[`ResourceUrlProvider`]. When loading resources dynamically with, for example, a JavaScript module loader, renaming @@ -1821,7 +1820,7 @@ will automatically configure Spring MVC to use it. [[boot-features-spring-mvc-template-engines]] ==== Template engines As well as REST web services, you can also use Spring MVC to serve dynamic HTML content. -Spring MVC supports a variety of templating technologies including Velocity, FreeMarker +Spring MVC supports a variety of templating technologies including Thymeleaf, FreeMarker and JSPs. Many other templating engines also ship their own Spring MVC integrations. Spring Boot includes auto-configuration support for the following templating engines: @@ -1829,7 +1828,6 @@ Spring Boot includes auto-configuration support for the following templating eng * http://freemarker.org/docs/[FreeMarker] * http://docs.groovy-lang.org/docs/next/html/documentation/template-engines.html#_the_markuptemplateengine[Groovy] * http://www.thymeleaf.org[Thymeleaf] - * http://velocity.apache.org[Velocity] (deprecated in 1.4) * http://mustache.github.io/[Mustache] TIP: JSPs should be avoided if possible, there are several diff --git a/spring-boot-samples/README.adoc b/spring-boot-samples/README.adoc index c286f642f68..a75684ab623 100644 --- a/spring-boot-samples/README.adoc +++ b/spring-boot-samples/README.adoc @@ -219,9 +219,6 @@ The following sample applications are provided: | link:spring-boot-sample-undertow-ssl[spring-boot-sample-undertow-ssl] | Embedded Undertow configured to use SSL -| link:spring-boot-sample-velocity[spring-boot-sample-velocity] -| Non-web application that uses Velocity templates - | link:spring-boot-sample-war[spring-boot-sample-war] | Web application packaged as a war file @@ -258,9 +255,6 @@ The following sample applications are provided: | link:spring-boot-sample-web-ui[spring-boot-sample-web-ui] | Web application with a basic UI built using Bootstrap and JQuery -| link:spring-boot-sample-web-velocity[spring-boot-sample-web-velocity] -| Web application that uses Velocity templates - | link:spring-boot-sample-webservices[spring-boot-sample-webservices] | Simple contract-first SOAP web service with Spring Web Services diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml index 40cb914ff93..5b4d6fc4d6f 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -92,7 +92,6 @@ spring-boot-sample-traditional spring-boot-sample-undertow spring-boot-sample-undertow-ssl - spring-boot-sample-velocity spring-boot-sample-war spring-boot-sample-web-freemarker spring-boot-sample-web-groovy-templates @@ -106,7 +105,6 @@ spring-boot-sample-web-static spring-boot-sample-web-thymeleaf3 spring-boot-sample-web-ui - spring-boot-sample-web-velocity spring-boot-sample-websocket-jetty spring-boot-sample-websocket-tomcat spring-boot-sample-websocket-undertow diff --git a/spring-boot-samples/spring-boot-sample-velocity/pom.xml b/spring-boot-samples/spring-boot-sample-velocity/pom.xml deleted file mode 100644 index f88826a4a2b..00000000000 --- a/spring-boot-samples/spring-boot-sample-velocity/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - 4.0.0 - - - org.springframework.boot - spring-boot-samples - 1.5.0.BUILD-SNAPSHOT - - spring-boot-sample-velocity - Spring Boot Web Velocity Sample - Spring Boot Web Velocity Sample - http://projects.spring.io/spring-boot/ - - Pivotal Software, Inc. - http://www.spring.io - - - ${basedir}/../.. - / - - - - org.springframework.boot - spring-boot-starter - - - org.springframework - spring-context-support - - - org.apache.velocity - velocity - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - false - - - - - diff --git a/spring-boot-samples/spring-boot-sample-velocity/src/main/java/sample/velocity/SampleVelocityApplication.java b/spring-boot-samples/spring-boot-sample-velocity/src/main/java/sample/velocity/SampleVelocityApplication.java deleted file mode 100644 index 4c8e0080106..00000000000 --- a/spring-boot-samples/spring-boot-sample-velocity/src/main/java/sample/velocity/SampleVelocityApplication.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 sample.velocity; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import org.apache.velocity.app.VelocityEngine; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.ui.velocity.VelocityEngineUtils; - -@SpringBootApplication -@Deprecated -public class SampleVelocityApplication implements CommandLineRunner { - - @Value("${application.message}") - private String message; - - @Autowired - private VelocityEngine engine; - - @Override - public void run(String... args) throws Exception { - Map model = new HashMap(); - model.put("time", new Date()); - model.put("message", this.message); - System.out.println(VelocityEngineUtils.mergeTemplateIntoString(this.engine, - "welcome.vm", "UTF-8", model)); - } - - public static void main(String[] args) throws Exception { - SpringApplication.run(SampleVelocityApplication.class, args); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-velocity/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-velocity/src/main/resources/application.properties deleted file mode 100644 index e504f79eb9c..00000000000 --- a/spring-boot-samples/spring-boot-sample-velocity/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -application.message: Hello, Andy diff --git a/spring-boot-samples/spring-boot-sample-velocity/src/main/resources/templates/welcome.vm b/spring-boot-samples/spring-boot-sample-velocity/src/main/resources/templates/welcome.vm deleted file mode 100644 index 7560db959d0..00000000000 --- a/spring-boot-samples/spring-boot-sample-velocity/src/main/resources/templates/welcome.vm +++ /dev/null @@ -1,2 +0,0 @@ -From application: $time -Message: $message \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-velocity/src/test/java/sample/velocity/SampleVelocityApplicationTests.java b/spring-boot-samples/spring-boot-sample-velocity/src/test/java/sample/velocity/SampleVelocityApplicationTests.java deleted file mode 100644 index 3f6d109e2ab..00000000000 --- a/spring-boot-samples/spring-boot-sample-velocity/src/test/java/sample/velocity/SampleVelocityApplicationTests.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 sample.velocity; - -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.rule.OutputCapture; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Basic integration tests for Velocity application with no web layer. - * - * @author Dave Syer - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class SampleVelocityApplicationTests { - - @ClassRule - public static OutputCapture output = new OutputCapture(); - - @Test - public void testVelocityTemplate() throws Exception { - String result = SampleVelocityApplicationTests.output.toString(); - assertThat(result).contains("Hello, Andy"); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-web-velocity/pom.xml b/spring-boot-samples/spring-boot-sample-web-velocity/pom.xml deleted file mode 100644 index 2a021451ea8..00000000000 --- a/spring-boot-samples/spring-boot-sample-web-velocity/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - 4.0.0 - - - org.springframework.boot - spring-boot-samples - 1.5.0.BUILD-SNAPSHOT - - spring-boot-sample-web-velocity - Spring Boot Web Velocity Sample - Spring Boot Web Velocity Sample - http://projects.spring.io/spring-boot/ - - Pivotal Software, Inc. - http://www.spring.io - - - ${basedir}/../.. - / - - - - org.springframework.boot - spring-boot-starter-velocity - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - false - - - - - diff --git a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/SampleWebVelocityApplication.java b/spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/SampleWebVelocityApplication.java deleted file mode 100644 index ae63ebcad03..00000000000 --- a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/SampleWebVelocityApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -package sample.web.velocity; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SampleWebVelocityApplication { - - public static void main(String[] args) throws Exception { - SpringApplication.run(SampleWebVelocityApplication.class, args); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/WelcomeController.java b/spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/WelcomeController.java deleted file mode 100644 index 417cccef3ac..00000000000 --- a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/WelcomeController.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 sample.web.velocity; - -import java.util.Date; -import java.util.Map; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -@Controller -public class WelcomeController { - - @Value("${application.message:Hello World}") - private String message = "Hello World"; - - @GetMapping("/") - public String welcome(Map model) { - model.put("time", new Date()); - model.put("message", this.message); - return "welcome"; - } - -} diff --git a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/application.properties deleted file mode 100644 index 11927c09665..00000000000 --- a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -application.message: Hello, Andy -spring.velocity.dateToolAttribute: dateTool \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/templates/error.vm b/spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/templates/error.vm deleted file mode 100644 index ace42110120..00000000000 --- a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/templates/error.vm +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - Something went wrong: ${status} ${error} - - - diff --git a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/templates/welcome.vm b/spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/templates/welcome.vm deleted file mode 100644 index 85f409d0f0c..00000000000 --- a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/resources/templates/welcome.vm +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - Time: -
    -
  • From controller: $time
  • -
  • From velocity: $dateTool
  • -
- Message: $message - - - diff --git a/spring-boot-samples/spring-boot-sample-web-velocity/src/test/java/sample/web/velocity/SampleWebVelocityApplicationTests.java b/spring-boot-samples/spring-boot-sample-web-velocity/src/test/java/sample/web/velocity/SampleWebVelocityApplicationTests.java deleted file mode 100644 index c7c76f243ba..00000000000 --- a/spring-boot-samples/spring-boot-sample-web-velocity/src/test/java/sample/web/velocity/SampleWebVelocityApplicationTests.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 sample.web.velocity; - -import java.util.Arrays; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Basic integration tests for Velocity application. - * - * @author Phillip Webb - * @author Andy Wilkinson - */ -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DirtiesContext -public class SampleWebVelocityApplicationTests { - - @Autowired - private TestRestTemplate restTemplate; - - @Test - public void testVelocityTemplate() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(entity.getBody()).contains("Hello, Andy"); - } - - @Test - public void testVelocityErrorTemplate() throws Exception { - HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); - HttpEntity requestEntity = new HttpEntity(headers); - - ResponseEntity responseEntity = this.restTemplate - .exchange("/does-not-exist", HttpMethod.GET, requestEntity, String.class); - - assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); - assertThat(responseEntity.getBody()) - .contains("Something went wrong: 404 Not Found"); - } - -} diff --git a/spring-boot-starters/pom.xml b/spring-boot-starters/pom.xml index 29937f00fe0..9f10942f9fe 100644 --- a/spring-boot-starters/pom.xml +++ b/spring-boot-starters/pom.xml @@ -66,7 +66,6 @@ spring-boot-starter-tomcat spring-boot-starter-undertow spring-boot-starter-validation - spring-boot-starter-velocity spring-boot-starter-web spring-boot-starter-websocket spring-boot-starter-web-services diff --git a/spring-boot-starters/spring-boot-starter-velocity/pom.xml b/spring-boot-starters/spring-boot-starter-velocity/pom.xml deleted file mode 100644 index 57b63a08681..00000000000 --- a/spring-boot-starters/spring-boot-starter-velocity/pom.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starters - 1.5.0.BUILD-SNAPSHOT - - spring-boot-starter-velocity - Spring Boot Velocity Starter - Starter for building MVC web applications using Velocity views. - Deprecated since 1.4 - http://projects.spring.io/spring-boot/ - - Pivotal Software, Inc. - http://www.spring.io - - - ${basedir}/../.. - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - commons-beanutils - commons-beanutils - - - commons-collections - commons-collections - - - commons-digester - commons-digester - - - org.apache.velocity - velocity - - - org.apache.velocity - velocity-tools - - - org.springframework - spring-context-support - - - diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml index 916c29bd24f..829d8092f26 100644 --- a/spring-boot/pom.xml +++ b/spring-boot/pom.xml @@ -109,16 +109,6 @@ tomcat-embed-jasper true
- - org.apache.velocity - velocity - true - - - org.apache.velocity - velocity-tools - true - org.assertj assertj-core diff --git a/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityToolboxView.java b/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityToolboxView.java deleted file mode 100644 index d667e830120..00000000000 --- a/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityToolboxView.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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.web.servlet.view.velocity; - -import java.io.InputStream; -import java.util.Map; - -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.context.Context; - -import org.springframework.aop.framework.ProxyFactory; -import org.springframework.core.io.ClassPathResource; -import org.springframework.web.servlet.view.velocity.VelocityToolboxView; - -/** - * Extended version of {@link VelocityToolboxView} that can load toolbox locations from - * the classpath as well as the servlet context. This is useful when running in an - * embedded web server. - * - * @author Phillip Webb - * @author Andy Wilkinson - * @since 1.2.5 - */ -@SuppressWarnings("deprecation") -public class EmbeddedVelocityToolboxView extends VelocityToolboxView { - - @Override - protected Context createVelocityContext(Map model, - HttpServletRequest request, HttpServletResponse response) throws Exception { - org.apache.velocity.tools.view.context.ChainedContext context = new org.apache.velocity.tools.view.context.ChainedContext( - new VelocityContext(model), getVelocityEngine(), request, response, - getServletContext()); - if (getToolboxConfigLocation() != null) { - setContextToolbox(context); - } - return context; - } - - @SuppressWarnings("unchecked") - private void setContextToolbox( - org.apache.velocity.tools.view.context.ChainedContext context) { - org.apache.velocity.tools.view.ToolboxManager toolboxManager = org.apache.velocity.tools.view.servlet.ServletToolboxManager - .getInstance(getToolboxConfigFileAwareServletContext(), - getToolboxConfigLocation()); - Map toolboxContext = toolboxManager.getToolbox(context); - context.setToolbox(toolboxContext); - } - - private ServletContext getToolboxConfigFileAwareServletContext() { - ProxyFactory factory = new ProxyFactory(); - factory.setTarget(getServletContext()); - factory.addAdvice(new GetResourceMethodInterceptor(getToolboxConfigLocation())); - return (ServletContext) factory.getProxy(getClass().getClassLoader()); - } - - /** - * {@link MethodInterceptor} to allow the calls to getResourceAsStream() to resolve - * the toolboxFile from the classpath. - */ - private static class GetResourceMethodInterceptor implements MethodInterceptor { - - private final String toolboxFile; - - GetResourceMethodInterceptor(String toolboxFile) { - if (toolboxFile != null && !toolboxFile.startsWith("/")) { - toolboxFile = "/" + toolboxFile; - } - this.toolboxFile = toolboxFile; - } - - @Override - public Object invoke(MethodInvocation invocation) throws Throwable { - if (invocation.getMethod().getName().equals("getResourceAsStream") - && invocation.getArguments()[0].equals(this.toolboxFile)) { - InputStream inputStream = (InputStream) invocation.proceed(); - if (inputStream == null) { - try { - inputStream = new ClassPathResource(this.toolboxFile, - Thread.currentThread().getContextClassLoader()) - .getInputStream(); - } - catch (Exception ex) { - // Ignore - } - } - return inputStream; - } - return invocation.proceed(); - } - - } - -} diff --git a/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityViewResolver.java b/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityViewResolver.java deleted file mode 100644 index b827cbedd7c..00000000000 --- a/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityViewResolver.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.web.servlet.view.velocity; - -import org.springframework.web.servlet.view.velocity.VelocityView; -import org.springframework.web.servlet.view.velocity.VelocityViewResolver; - -/** - * Extended version of {@link VelocityViewResolver} that uses - * {@link EmbeddedVelocityToolboxView} when the {@link #setToolboxConfigLocation(String) - * toolboxConfigLocation} is set. - * - * @author Phillip Webb - * @since 1.2.5 - * @deprecated as of 1.4 following the deprecation of Velocity support in Spring Framework - * 4.3 - */ -@Deprecated -public class EmbeddedVelocityViewResolver extends VelocityViewResolver { - - private String toolboxConfigLocation; - - @Override - protected void initApplicationContext() { - if (this.toolboxConfigLocation != null) { - if (VelocityView.class.equals(getViewClass())) { - this.logger.info("Using EmbeddedVelocityToolboxView instead of " - + "default VelocityView due to specified toolboxConfigLocation"); - setViewClass(EmbeddedVelocityToolboxView.class); - } - } - super.initApplicationContext(); - } - - @Override - public void setToolboxConfigLocation(String toolboxConfigLocation) { - super.setToolboxConfigLocation(toolboxConfigLocation); - this.toolboxConfigLocation = toolboxConfigLocation; - } - -} diff --git a/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/package-info.java b/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/package-info.java deleted file mode 100644 index 751e75957c4..00000000000 --- a/spring-boot/src/main/java/org/springframework/boot/web/servlet/view/velocity/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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. - */ - -/** - * Velocity support classes. - */ -package org.springframework.boot.web.servlet.view.velocity; diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityToolboxViewTests.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityToolboxViewTests.java deleted file mode 100644 index d696e10a96a..00000000000 --- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityToolboxViewTests.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.web.servlet.view.velocity; - -import java.util.LinkedHashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.tools.ToolContext; -import org.junit.Test; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.mock.web.MockServletContext; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.servlet.view.velocity.VelocityConfigurer; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link EmbeddedVelocityToolboxView}. - * - * @author Phillip Webb - */ -@SuppressWarnings("deprecation") -public class EmbeddedVelocityToolboxViewTests { - - private static final String PATH = EmbeddedVelocityToolboxViewTests.class.getPackage() - .getName().replace(".", "/"); - - @Test - public void loadsContextFromClassPath() throws Exception { - ToolContext context = getToolContext(PATH + "/toolbox.xml"); - assertThat(context.getToolbox().keySet()).contains("math"); - } - - @Test - public void loadsWithoutConfig() throws Exception { - ToolContext context = getToolContext(null); - assertThat(context).isNotNull(); - } - - private ToolContext getToolContext(String toolboxConfigLocation) throws Exception { - AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); - context.setServletContext(new MockServletContext()); - context.register(Config.class); - context.refresh(); - EmbeddedVelocityToolboxView view = context - .getBean(EmbeddedVelocityToolboxView.class); - view.setToolboxConfigLocation(toolboxConfigLocation); - Map model = new LinkedHashMap(); - HttpServletRequest request = new MockHttpServletRequest(); - HttpServletResponse response = new MockHttpServletResponse(); - ToolContext toolContext = (ToolContext) view.createVelocityContext(model, request, - response); - context.close(); - return toolContext; - } - - @Configuration - static class Config { - - @Bean - public EmbeddedVelocityToolboxView view() { - EmbeddedVelocityToolboxView view = new EmbeddedVelocityToolboxView(); - view.setUrl("http://example.com"); - return view; - } - - @Bean - public VelocityConfigurer velocityConfigurer() { - return new VelocityConfigurer(); - } - - } - -} diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityViewResolverTests.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityViewResolverTests.java deleted file mode 100644 index aec9b4cf458..00000000000 --- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/view/velocity/EmbeddedVelocityViewResolverTests.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.web.servlet.view.velocity; - -import org.junit.Test; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.mock.web.MockServletContext; -import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.servlet.view.velocity.VelocityConfigurer; -import org.springframework.web.servlet.view.velocity.VelocityView; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link EmbeddedVelocityViewResolver}. - * - * @author Phillip Webb - */ -@SuppressWarnings("deprecation") -public class EmbeddedVelocityViewResolverTests { - - @Test - public void standardViewWithoutToolboxConfig() throws Exception { - ApplicationContext context = loadContext(WithoutToolboxConfig.class); - EmbeddedVelocityViewResolver resolver = context - .getBean(EmbeddedVelocityViewResolver.class); - Object viewClass = ReflectionTestUtils.getField(resolver, "viewClass"); - assertThat(viewClass).isEqualTo(VelocityView.class); - } - - @Test - public void embeddedViewWithToolboxConfig() throws Exception { - ApplicationContext context = loadContext(WithToolboxConfig.class); - EmbeddedVelocityViewResolver resolver = context - .getBean(EmbeddedVelocityViewResolver.class); - Object viewClass = ReflectionTestUtils.getField(resolver, "viewClass"); - assertThat(viewClass).isEqualTo(EmbeddedVelocityToolboxView.class); - } - - private ApplicationContext loadContext(Class config) { - AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); - context.setServletContext(new MockServletContext()); - context.register(config); - context.refresh(); - return context; - } - - @Configuration - static class WithoutToolboxConfig { - - @Bean - public EmbeddedVelocityViewResolver resolver() { - return new EmbeddedVelocityViewResolver(); - } - - @Bean - public VelocityConfigurer velocityConfigurer() { - return new VelocityConfigurer(); - } - - } - - @Configuration - static class WithToolboxConfig { - - @Bean - public EmbeddedVelocityViewResolver resolver() { - EmbeddedVelocityViewResolver resolver = new EmbeddedVelocityViewResolver(); - resolver.setToolboxConfigLocation("/toolbox.xml"); - return resolver; - } - - @Bean - public VelocityConfigurer velocityConfigurer() { - return new VelocityConfigurer(); - } - - } - -} diff --git a/spring-boot/src/test/resources/org/springframework/boot/web/servlet/view/velocity/toolbox.xml b/spring-boot/src/test/resources/org/springframework/boot/web/servlet/view/velocity/toolbox.xml deleted file mode 100644 index 6be5e9f4d89..00000000000 --- a/spring-boot/src/test/resources/org/springframework/boot/web/servlet/view/velocity/toolbox.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - math - application - org.apache.velocity.tools.generic.MathTool - -