Repository: flex-blazeds Updated Branches: refs/heads/develop fdbf19e48 -> cf0d1eb59
- Added an initial implementation of a BlazeDS Spring-Boot Starter Project: http://git-wip-us.apache.org/repos/asf/flex-blazeds/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-blazeds/commit/5340320f Tree: http://git-wip-us.apache.org/repos/asf/flex-blazeds/tree/5340320f Diff: http://git-wip-us.apache.org/repos/asf/flex-blazeds/diff/5340320f Branch: refs/heads/develop Commit: 5340320f7425270ce615ec29874b33cce5b9ac2d Parents: fdbf19e Author: Christofer Dutz <[email protected]> Authored: Thu Mar 24 15:45:57 2016 +0100 Committer: Christofer Dutz <[email protected]> Committed: Thu Mar 24 15:45:57 2016 +0100 ---------------------------------------------------------------------- blazeds-spring-boot-starter/pom.xml | 101 +++++++++++++++++++ .../spring/BlazeDsAutoConfiguration.java | 70 +++++++++++++ 2 files changed, 171 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/5340320f/blazeds-spring-boot-starter/pom.xml ---------------------------------------------------------------------- diff --git a/blazeds-spring-boot-starter/pom.xml b/blazeds-spring-boot-starter/pom.xml new file mode 100644 index 0000000..5f60c56 --- /dev/null +++ b/blazeds-spring-boot-starter/pom.xml @@ -0,0 +1,101 @@ +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.flex.blazeds</groupId> + <artifactId>blazeds</artifactId> + <version>4.7.3-SNAPSHOT</version> + </parent> + + <artifactId>blazeds-spring-boot-starter</artifactId> + + <dependencies> + <!-- Spring-Boot dependencies --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-autoconfigure</artifactId> + <version>1.3.3.RELEASE</version> + </dependency> + + <!-- Add a reference to Apache Flex BlazeDS --> + <dependency> + <groupId>org.apache.flex.blazeds</groupId> + <artifactId>flex-messaging-core</artifactId> + <version>4.7.3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.flex.blazeds</groupId> + <artifactId>flex-messaging-common</artifactId> + <version>4.7.3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.flex.blazeds</groupId> + <artifactId>flex-messaging-proxy</artifactId> + <version>4.7.3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.flex.blazeds</groupId> + <artifactId>flex-messaging-remoting</artifactId> + <version>4.7.3-SNAPSHOT</version> + </dependency> + + <!-- + We'll use Spring Flex-Integration for actually + running BlazeDS in Spring. + --> + <dependency> + <groupId>org.springframework.flex</groupId> + <artifactId>spring-flex-core</artifactId> + <version>1.5.2.RELEASE</version> + <exclusions> + <exclusion> + <groupId>com.adobe.blazeds</groupId> + <artifactId>blazeds-core</artifactId> + </exclusion> + <exclusion> + <groupId>com.adobe.blazeds</groupId> + <artifactId>blazeds-common</artifactId> + </exclusion> + <exclusion> + <groupId>com.adobe.blazeds</groupId> + <artifactId>blazeds-proxy</artifactId> + </exclusion> + <exclusion> + <groupId>com.adobe.blazeds</groupId> + <artifactId>blazeds-remoting</artifactId> + </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/5340320f/blazeds-spring-boot-starter/src/main/java/org/apache/flex/blazeds/spring/BlazeDsAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/blazeds-spring-boot-starter/src/main/java/org/apache/flex/blazeds/spring/BlazeDsAutoConfiguration.java b/blazeds-spring-boot-starter/src/main/java/org/apache/flex/blazeds/spring/BlazeDsAutoConfiguration.java new file mode 100644 index 0000000..d516828 --- /dev/null +++ b/blazeds-spring-boot-starter/src/main/java/org/apache/flex/blazeds/spring/BlazeDsAutoConfiguration.java @@ -0,0 +1,70 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.flex.blazeds.spring; + +import flex.messaging.MessageBroker; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnResource; +import org.springframework.core.io.ResourceLoader; +import org.springframework.flex.core.MessageBrokerFactoryBean; + +import javax.servlet.ServletContext; + +/** + * Created by christoferdutz on 21.03.16. + */ +@ConditionalOnWebApplication +@ConditionalOnResource(resources = BlazeDsAutoConfiguration.SERVICES_CONFIG_PATH) +public class BlazeDsAutoConfiguration { + + public static final String SERVICES_CONFIG_PATH = "classpath:/META-INF/flex/services-config.xml"; + + @Autowired + private ServletContext context; + + @Autowired + private ResourceLoader resourceLoader; + + @Bean + public MessageBroker messageBroker() throws Exception { + // We'll use the Spring-Flex-Integration factories. + MessageBrokerFactoryBean factoryBean = new MessageBrokerFactoryBean(); + + // TODO: Do all the special configuration magic here ... + //factoryBean.setConfigProcessors(null); + //factoryBean.setConfigurationManager(null); + + // Setup the Spring stuff. + factoryBean.setResourceLoader(resourceLoader); + factoryBean.setServletContext(context); + + // The most important option: Where the services-config.xml is located. + factoryBean.setServicesConfigPath(SERVICES_CONFIG_PATH); + + // This actually internally creates and configures the message broker. + factoryBean.afterPropertiesSet(); + + // Return the instance. + return factoryBean.getObject(); + } + +}
