You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2016/03/26 10:59:47 UTC
flex-blazeds git commit: - Continued implementing the Spring-Boot
starter (This version is actually able to start and configure a BlazeDS
instance using Spring-Boot and auto-detect servies marked with the
"RemotingDestination" annotation) - Invoking auto
Repository: flex-blazeds
Updated Branches:
refs/heads/develop 1a1dba1dd -> de985b1e4
- Continued implementing the Spring-Boot starter (This version is actually able to start and configure a BlazeDS instance using Spring-Boot and auto-detect servies marked with the "RemotingDestination" annotation)
- Invoking auto detected remoting destinations from a flex client works.
Project: http://git-wip-us.apache.org/repos/asf/flex-blazeds/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-blazeds/commit/de985b1e
Tree: http://git-wip-us.apache.org/repos/asf/flex-blazeds/tree/de985b1e
Diff: http://git-wip-us.apache.org/repos/asf/flex-blazeds/diff/de985b1e
Branch: refs/heads/develop
Commit: de985b1e4306468d88bdb80b901cc1e9ac070cdc
Parents: 1a1dba1
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Sat Mar 26 10:59:39 2016 +0100
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Sat Mar 26 10:59:39 2016 +0100
----------------------------------------------------------------------
opt/blazeds-spring-boot-starter/pom.xml | 29 +++++----
.../spring/BlazeDsAutoConfiguration.java | 68 ++++++++++++++++++--
2 files changed, 80 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/de985b1e/opt/blazeds-spring-boot-starter/pom.xml
----------------------------------------------------------------------
diff --git a/opt/blazeds-spring-boot-starter/pom.xml b/opt/blazeds-spring-boot-starter/pom.xml
index 9a49f03..eb93b3b 100644
--- a/opt/blazeds-spring-boot-starter/pom.xml
+++ b/opt/blazeds-spring-boot-starter/pom.xml
@@ -34,6 +34,23 @@ limitations under the License.
<artifactId>spring-boot-autoconfigure</artifactId>
<version>1.3.3.RELEASE</version>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>4.2.3.RELEASE</version>
+ </dependency>
+
+ <!--
+ A s we rely on the Web layer being configured,
+ we can also take care of providing it. This way
+ all you need is a dependency to blazeds-spring-boot-starter
+ and you have all you need.
+ -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <version>1.3.3.RELEASE</version>
+ </dependency>
<!-- Add a reference to Apache Flex BlazeDS -->
<dependency>
@@ -84,18 +101,6 @@ limitations under the License.
</exclusion>
</exclusions>
</dependency>
-
- <!--
- As we rely on the Web layer being configured,
- we can also take care of providing it. This way
- all you need is a dependency to blazeds-spring-boot-starter
- and you have all you need.
- -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- <version>1.3.3.RELEASE</version>
- </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/de985b1e/opt/blazeds-spring-boot-starter/src/main/java/org/apache/flex/blazeds/spring/BlazeDsAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/opt/blazeds-spring-boot-starter/src/main/java/org/apache/flex/blazeds/spring/BlazeDsAutoConfiguration.java b/opt/blazeds-spring-boot-starter/src/main/java/org/apache/flex/blazeds/spring/BlazeDsAutoConfiguration.java
index 3d5ad46..140a457 100644
--- a/opt/blazeds-spring-boot-starter/src/main/java/org/apache/flex/blazeds/spring/BlazeDsAutoConfiguration.java
+++ b/opt/blazeds-spring-boot-starter/src/main/java/org/apache/flex/blazeds/spring/BlazeDsAutoConfiguration.java
@@ -26,16 +26,23 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat
import org.springframework.context.annotation.Bean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnResource;
import org.springframework.core.io.ResourceLoader;
+import org.springframework.flex.config.RemotingAnnotationPostProcessor;
import org.springframework.flex.core.MessageBrokerFactoryBean;
+import org.springframework.flex.servlet.MessageBrokerHandlerAdapter;
+import org.springframework.web.context.support.ServletContextAwareProcessor;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
+import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
+import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import javax.servlet.ServletContext;
+import java.util.Properties;
/**
* Created by christoferdutz on 21.03.16.
*/
@ConditionalOnWebApplication
@ConditionalOnResource(resources = BlazeDsAutoConfiguration.SERVICES_CONFIG_PATH)
-public class BlazeDsAutoConfiguration {
+public class BlazeDsAutoConfiguration extends WebMvcConfigurationSupport {
public static final String SERVICES_CONFIG_PATH = "classpath:/META-INF/flex/services-config.xml";
@@ -46,10 +53,8 @@ public class BlazeDsAutoConfiguration {
private ResourceLoader resourceLoader;
@Bean
- public MessageBroker messageBroker() throws Exception {
- // We'll use the Spring-Flex-Integration factories.
+ public MessageBrokerFactoryBean messageBrokerFactoryBean() throws Exception {
MessageBrokerFactoryBean factoryBean = new MessageBrokerFactoryBean();
-
// TODO: Do all the special configuration magic here ...
//factoryBean.setConfigProcessors(null);
//factoryBean.setConfigurationManager(null);
@@ -62,10 +67,63 @@ public class BlazeDsAutoConfiguration {
factoryBean.setServicesConfigPath(SERVICES_CONFIG_PATH);
// This actually internally creates and configures the message broker.
- factoryBean.afterPropertiesSet();
+ //factoryBean.afterPropertiesSet();
+
+ return factoryBean;
+ }
+ /**
+ * Create and configure an instance of the MessageBroker.
+ *
+ * @return MessageBroker instance.
+ * @throws Exception in case anything went wrong.
+ */
+ @Bean
+ public MessageBroker _messageBroker(MessageBrokerFactoryBean factoryBean) throws Exception {
// Return the instance.
return factoryBean.getObject();
}
+ /**
+ * The MessageBrokerHandlerAdapter intercepts any requests to the
+ * MVC Servlet, detects the ones that match valid BlazeDS endpoints
+ * and redirects them to the matching endpoint implementation.
+ *
+ * @return MessageBrokerHandlerAdapter instance
+ */
+ @Bean
+ public MessageBrokerHandlerAdapter messageBrokerHandlerAdapter() {
+ return new MessageBrokerHandlerAdapter();
+ }
+
+ /**
+ * Tell the Dispatcher Servlet to redirect any requests in the
+ * "/messagebroker/" context to the BlazeDS MessageBroker.
+ *
+ * @return SimpleUrlHandlerMapping instance.
+ */
+ @Bean
+ public SimpleUrlHandlerMapping sampleServletMapping() {
+ SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
+ mapping.setOrder(Integer.MAX_VALUE - 2);
+
+ Properties urlProperties = new Properties();
+ urlProperties.put("/messagebroker/*", "_messageBroker");
+
+ mapping.setMappings(urlProperties);
+ return mapping;
+ }
+
+ /**
+ * Post processor that automatically scans all created beans for
+ * ones annotated with @RemotingDestination and automatically adds
+ * these to the list of destinations at the MessageBroker.
+ *
+ * @return RemotingAnnotationPostProcessor instance.
+ */
+ @Bean
+ public RemotingAnnotationPostProcessor remotingAnnotationPostProcessor() {
+ return new RemotingAnnotationPostProcessor();
+ }
+
}