2017-03-16 4 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> 

それでは、どのように私は、これは春の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

関連する問題