2017-03-16 18 views
0

我需要在JAVA中以编程方式加载现有的Spring-webflow流来检查它的安全标记。如何以编程方式加载Spring Webflow流并获取其内容

我的目标是在特定事件发生后检查安全标签。

Spring-webflow 2.4在这里使用。我的流程看起来像这样:

<?xml version="1.0" encoding="UTF-8"?> 
<flow xmlns="http://www.springframework.org/schema/webflow" 
xmlns:ns0="http://www.w3.org/2001/XMLSchema-instance" 
ns0:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> 


<secured attributes="RIGHT_1,RIGHT_2" /> 

<view-state id="someViewState"> 
[...] 
</view-state> 

[...] 

</flow> 

那么我怎么能通过spring API获取这个流“内容”?我试图通过org.springframework.webflow.config包的类找到我的方式,但我没有在干草中找到针。我甚至无法成功加载流。

我在流程中工作了一段时间,但我从来不需要在Java代码中访问它们。

Thx,对于任何提示。

回答

0

我得到了它的自己:

在扩展org.springframework.web.servlet.mvc.AbstractController一类

,你可以这样做:

// get the application Context 
ApplicationContext context = getApplicationContext(); 
// get webflowController, must be configured in your webflowConfig file 
FlowController controller = (FlowController)context.getBean("flowController"); 
FlowExecutorImpl flowExecutorImpl = (FlowExecutorImpl)controller.getFlowExecutor(); 
FlowDefinitionRegistryImpl flowDefinitionRegistryImpl = (FlowDefinitionRegistryImpl)flowExecutorImpl.getDefinitionLocator(); 

// flowId is the id of the flow you want to check 
FlowDefinition flowDefinition = flowDefinitionRegistryImpl.getFlowDefinition(flowId); 

MutableAttributeMap<Object> attributes = flowDefinition.getAttributes(); 

// finally the SecurityRule Object that you can pass to a specific AccessDecisionManager 
SecurityRule securityRule = (SecurityRule)attributes.get("secured"); 
+1

你可以使用一个FlowExecutionListener – rptmat57

相关问题