2017-03-16 1 views
0

JAVA에서 프로그래밍 방식으로 기존 스프링 웹 플로우를로드하여 보안 태그를 확인해야합니다.프로그래밍 방식으로 Spring 웹 플로우 플로우를로드하고 컨텐츠를 얻는 방법

내 목표는 특정 이벤트 후에 보안 태그를 확인하는 것입니다.

여기에는 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