variable autowiring

This commit is contained in:
Keith Donald
2008-02-29 17:14:05 +00:00
parent 940a6c9d1b
commit f8d79915b0
3 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
package org.springframework.webflow.engine;
import org.springframework.webflow.execution.RequestContext;
public interface VariableValueFactory {
public Object createVariableValue(RequestContext context);
public Object restoreReferences(Object value, RequestContext context);
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2004-2008 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.webflow.engine.support;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.webflow.engine.VariableValueFactory;
import org.springframework.webflow.execution.RequestContext;
public class BeanFactoryVariableValueFactory implements VariableValueFactory {
private Class type;
private AutowireCapableBeanFactory beanFactory;
public BeanFactoryVariableValueFactory(Class type, AutowireCapableBeanFactory beanFactory) {
this.type = type;
this.beanFactory = beanFactory;
}
public Object createVariableValue(RequestContext context) {
return beanFactory.createBean(type);
}
public Object restoreReferences(Object value, RequestContext context) {
beanFactory.autowireBeanProperties(value, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
return value;
}
}

View File

@@ -0,0 +1,10 @@
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<var name="flow-foo" class="org.springframework.webflow.TestBean"/>
<var name="conversation-foo" class="org.springframework.webflow.TestBean" scope="conversation"/>
<end-state id="end"/>
</flow>