首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何以编程方式加载Spring webflow流并获取其内容

如何以编程方式加载Spring webflow流并获取其内容
EN

Stack Overflow用户
提问于 2017-03-16 20:47:28
回答 1查看 652关注 0票数 1

我需要在JAVA中以编程方式加载一个现有的Spring-webflow流,以检查它的安全标记。

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

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

代码语言:javascript
复制
<?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,任何提示。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-16 22:33:59

我自己弄的:

在扩展org.springframework.web.servlet.mvc.AbstractController,的类中,您可以这样做:

代码语言:javascript
复制
// 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");
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42834547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档