Skip to content

Commit

Permalink
Version 1.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
xdcrafts committed Jan 19, 2017
1 parent d632c26 commit a76902a
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 70 deletions.
4 changes: 2 additions & 2 deletions flower-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<groupId>com.github.xdcrafts</groupId>
<artifactId>flower</artifactId>
<relativePath>..</relativePath>
<version>1.3.4</version>
<version>1.3.5</version>
</parent>

<dependencies>
<dependency>
<groupId>com.github.xdcrafts</groupId>
<artifactId>flower-tools</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
4 changes: 2 additions & 2 deletions flower-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<groupId>com.github.xdcrafts</groupId>
<artifactId>flower</artifactId>
<relativePath>..</relativePath>
<version>1.3.4</version>
<version>1.3.5</version>
</parent>

<dependencies>
<dependency>
<groupId>com.github.xdcrafts</groupId>
<artifactId>flower-core</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package com.github.xdcrafts.flower.spring.impl;

import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.GenericBeanDefinition;
Expand All @@ -31,16 +32,15 @@
*/
public class DefaultActionDefinitionFactory implements BeanDefinitionRegistryPostProcessor {

private final String namespace;
private final Map<String, String> actions;
private String namespace;
private Map<String, String> actions;

public DefaultActionDefinitionFactory(Map<String, String> actions) {
this.namespace = null;
this.actions = actions;
public void setNamespace(String namespace) {
this.namespace = namespace;
}

public DefaultActionDefinitionFactory(String namespace, Map<String, String> actions) {
this.namespace = namespace;
@Required
public void setActions(Map<String, String> actions) {
this.actions = actions;
}

Expand All @@ -50,11 +50,11 @@ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) t
final String name = entry.getKey();
final String qualifiedName = Named.qualifiedName(this.namespace, name);
final Object method = entry.getValue();
final ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
constructorArgumentValues.addGenericArgumentValue(method);
final MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("method", method);
final GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(DefaultActionFactory.class);
beanDefinition.setConstructorArgumentValues(constructorArgumentValues);
beanDefinition.setPropertyValues(propertyValues);
registry.registerBeanDefinition(qualifiedName, beanDefinition);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.github.xdcrafts.flower.spring.impl;

import com.github.xdcrafts.flower.core.impl.actions.DefaultAction;
import org.springframework.beans.factory.annotation.Required;

/**
* Spring factory bean for default action that uses bean name as action name.
Expand All @@ -25,9 +26,10 @@
public class DefaultActionFactory
extends AbstractActionFactoryBean<DefaultAction> {

private final String method;
private String method;

public DefaultActionFactory(String method) {
@Required
public void setMethod(String method) {
this.method = method;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.github.xdcrafts.flower.core.Middleware;
import com.github.xdcrafts.flower.core.impl.actions.DefaultAction;
import com.github.xdcrafts.flower.core.impl.extensions.DefaultExtension;
import org.springframework.beans.factory.annotation.Required;

import java.security.SecureRandom;
import java.util.Collections;
Expand All @@ -34,17 +35,21 @@ public class DefaultExtensionFactory extends AbstractActionFactoryBean<DefaultEx

private static final SecureRandom RANDOM = new SecureRandom();

private final Object action;
private final Map configuration;

private Object action;
private Map configuration;
private MiddlewareDefinition middleware;

public void setMiddleware(MiddlewareDefinition middleware) {
this.middleware = middleware;
}

public DefaultExtensionFactory(Object action, Map configuration) {
@Required
public void setAction(Object action) {
this.action = action;
}

@Required
public void setConfiguration(Map configuration) {
this.configuration = configuration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.github.xdcrafts.flower.core.Extension;
import com.github.xdcrafts.flower.core.Selector;
import com.github.xdcrafts.flower.core.impl.DefaultFeature;
import org.springframework.beans.factory.annotation.Required;

import java.util.Map;

Expand All @@ -27,9 +28,10 @@
*/
public class DefaultFeatureFactory extends AbstractNameAwareFactoryBean<DefaultFeature> {

private final Map<Extension, Selector> extensions;
private Map<Extension, Selector> extensions;

public DefaultFeatureFactory(Map<Extension, Selector> extensions) {
@Required
public void setExtensions(Map<Extension, Selector> extensions) {
this.extensions = extensions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.github.xdcrafts.flower.spring.impl;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import com.github.xdcrafts.flower.core.Middleware;
Expand All @@ -38,24 +39,24 @@ private static List<String> split(String string) {
return Arrays.stream(string.split(SPLITTER_REGEX)).map(String::trim).collect(Collectors.toList());
}

private final boolean shared;
private final String namespace;
private final Map<String, String> rawDefinition;
private boolean shared = true;
private String namespace;
private Map<String, String> rawDefinition;
private Map<String, List<Middleware>> definition;

public MiddlewareDefinition(boolean shared, Map<String, String> definition) {
this(shared, null, definition);
public void setShared(boolean shared) {
this.shared = shared;
}

public MiddlewareDefinition(boolean shared, String namespace, Map<String, String> definition) {
if (definition == null) {
throw new IllegalArgumentException("'definition' can not be null.");
}
this.shared = shared;
this.rawDefinition = definition;
public void setNamespace(String namespace) {
this.namespace = namespace;
}

@Required
public void setDefinition(Map<String, String> definition) {
this.rawDefinition = definition;
}

public boolean isShared() {
return shared;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.github.xdcrafts.flower.spring.impl.flows;

import com.github.xdcrafts.flower.core.impl.flows.AsyncFlow;
import org.springframework.beans.factory.annotation.Required;

import java.util.List;
import java.util.Map;
Expand All @@ -30,8 +31,12 @@ public class AsyncFlowFactory extends AbstractFlowFactoryBean<AsyncFlow> {
private List<Object> actions;
private Map configuration;

public AsyncFlowFactory(List<Object> actions, Map configuration) {
public void setActions(List<Object> actions) {
this.actions = actions;
}

@Required
public void setConfiguration(Map configuration) {
this.configuration = configuration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.github.xdcrafts.flower.spring.impl.flows;

import com.github.xdcrafts.flower.core.impl.flows.SyncFlow;
import org.springframework.beans.factory.annotation.Required;

import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -28,7 +29,8 @@ public class SyncFlowFactory extends AbstractFlowFactoryBean<SyncFlow> {

private List<Object> actions;

public SyncFlowFactory(List<Object> actions) {
@Required
public void setActions(List<Object> actions) {
this.actions = actions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.github.xdcrafts.flower.core.impl.selectors.KeywordSelector;
import com.github.xdcrafts.flower.spring.impl.AbstractActionFactoryBean;
import org.springframework.beans.factory.annotation.Required;

/**
* KeywordSelector factory bean.
Expand All @@ -26,7 +27,8 @@ public class KeywordSelectorFactory extends AbstractActionFactoryBean<KeywordSel

private String keyword;

public KeywordSelectorFactory(String keyword) {
@Required
public void setKeyword(String keyword) {
this.keyword = keyword;
}

Expand Down
12 changes: 6 additions & 6 deletions flower-spring/src/test/resources/application-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,34 +78,34 @@
<!-- Middleware start -->

<bean class="com.github.xdcrafts.flower.spring.impl.MiddlewareDefinition">
<constructor-arg name="shared" value="true"/>
<constructor-arg name="definition">
<property name="shared" value="true"/>
<property name="definition">
<map>
<entry key="selector" value="loggingMiddleware"/>
</map>
</constructor-arg>
</property>
</bean>

<!-- Middleware end -->

<!-- Actions start -->

<bean id="selector" class="com.github.xdcrafts.flower.spring.impl.selectors.KeywordSelectorFactory">
<constructor-arg name="keyword" value="request.type"/>
<property name="keyword" value="request.type"/>
</bean>

<!-- Actions end -->

<!-- Flows start -->

<bean id="mainFlow" class="com.github.xdcrafts.flower.spring.impl.flows.SyncFlowFactory">
<constructor-arg name="actions">
<property name="actions">
<list>
<value>authenticator::authenticate</value>
<ref bean="selector"/>
<value>receiver::receive</value>
</list>
</constructor-arg>
</property>
</bean>

<!-- Flows end -->
Expand Down
28 changes: 14 additions & 14 deletions flower-spring/src/test/resources/features/email-feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,65 +37,65 @@
<!-- Middleware start -->

<bean class="com.github.xdcrafts.flower.spring.impl.MiddlewareDefinition">
<constructor-arg name="shared" value="true"/>
<constructor-arg name="namespace" value="email"/>
<constructor-arg name="definition">
<property name="shared" value="true"/>
<property name="namespace" value="email"/>
<property name="definition">
<map>
<entry key="Validate, Authorize, Send" value="loggingMiddleware"/>
</map>
</constructor-arg>
</property>
</bean>

<!-- Middleware end -->

<!-- Actions start -->

<bean class="com.github.xdcrafts.flower.spring.impl.DefaultActionDefinitionFactory">
<constructor-arg name="namespace" value="email"/>
<constructor-arg name="actions">
<property name="namespace" value="email"/>
<property name="actions">
<map>
<entry key="Validate" value="email.RequestValidator::validate"/>
<entry key="Authorize" value="email.Authorizer::authorize"/>
<entry key="Send" value="email.Sender::send"/>
</map>
</constructor-arg>
</property>
</bean>

<!-- Actions end -->

<!-- Flows start -->

<bean id="email.Flow" class="com.github.xdcrafts.flower.spring.impl.flows.SyncFlowFactory">
<constructor-arg name="actions">
<property name="actions">
<list>
<ref bean="email.Validate"/>
<ref bean="email.Authorize"/>
<ref bean="email.Send"/>
</list>
</constructor-arg>
</property>
</bean>

<!-- Flows end -->

<!-- Extensions start -->

<bean id="email.Extension" class="com.github.xdcrafts.flower.spring.impl.DefaultExtensionFactory">
<constructor-arg name="action" ref="email.Flow"/>
<constructor-arg name="configuration">
<property name="action" ref="email.Flow"/>
<property name="configuration">
<map>
<entry key="keyword-value" value="email"/>
</map>
</constructor-arg>
</property>
</bean>

<!-- Extensions end -->

<bean id="email.Feature" class="com.github.xdcrafts.flower.spring.impl.DefaultFeatureFactory">
<constructor-arg name="extensions">
<property name="extensions">
<map>
<entry key-ref="email.Extension" value-ref="selector"/>
</map>
</constructor-arg>
</property>
</bean>

</beans>
Expand Down
Loading

0 comments on commit a76902a

Please sign in to comment.