Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何以编程方式加载SpringWebFlow流并获取其内容_Java_Spring_Spring Mvc_Spring Webflow - Fatal编程技术网

Java 如何以编程方式加载SpringWebFlow流并获取其内容

Java 如何以编程方式加载SpringWebFlow流并获取其内容,java,spring,spring-mvc,spring-webflow,Java,Spring,Spring Mvc,Spring Webflow,我需要在JAVA中以编程方式加载现有的SpringWebFlow流,以检查它的安全标记 我的目标是在特定事件之后检查安全标签 这里使用SpringWebFlow2.4。我的流程如下所示: <?xml version="1.0" encoding="UTF-8"?> <flow xmlns="http://www.springframework.org/schema/webflow" xmlns:ns0="http://www.w3.org/2001/XMLSchema-inst

我需要在JAVA中以编程方式加载现有的SpringWebFlow流,以检查它的安全标记

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

这里使用SpringWebFlow2.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>

[...]
[...]
那么,如何通过SpringAPI获取这些流的“内容”?我试图通过org.springframework.webflow.config包中的类找到自己的方法,但我没有找到解决办法。我甚至无法成功加载流

我使用流已经有一段时间了,但我从不需要在Java代码中访问它们

谢谢,有什么提示吗。

我自己弄到的:

在扩展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");
//获取应用程序上下文
ApplicationContext上下文=getApplicationContext();
//必须在webflowConfig文件中配置get-webflowController
FlowController=(FlowController)context.getBean(“FlowController”);
FlowExecuteImpl FlowExecuteImpl=(FlowExecuteImpl)控制器。getFlowExecutor();
FlowDefinitionRegistryImpl FlowDefinitionRegistryImpl=(FlowDefinitionRegistryImpl)FlowExecuteImpl.getDefinitionLocator();
//flowId是要检查的流的id
FlowDefinition FlowDefinition=flowDefinitionRegistryImpl.getFlowDefinition(flowId);
MutableAttributeMap attributes=flowDefinition.getAttributes();
//最后是可以传递给特定AccessDecisionManager的SecurityRule对象
SecurityRule SecurityRule=(SecurityRule)attributes.get(“安全”);
我自己买的:

在扩展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");
//获取应用程序上下文
ApplicationContext上下文=getApplicationContext();
//必须在webflowConfig文件中配置get-webflowController
FlowController=(FlowController)context.getBean(“FlowController”);
FlowExecuteImpl FlowExecuteImpl=(FlowExecuteImpl)控制器。getFlowExecutor();
FlowDefinitionRegistryImpl FlowDefinitionRegistryImpl=(FlowDefinitionRegistryImpl)FlowExecuteImpl.getDefinitionLocator();
//flowId是要检查的流的id
FlowDefinition FlowDefinition=flowDefinitionRegistryImpl.getFlowDefinition(flowId);
MutableAttributeMap attributes=flowDefinition.getAttributes();
//最后是可以传递给特定AccessDecisionManager的SecurityRule对象
SecurityRule SecurityRule=(SecurityRule)attributes.get(“安全”);

您可以使用FlowExecutionListener您可以使用FlowExecutionListener