컨텍스트 서비스는 SCA(Service Component Architecture) 호출 경로를 따라 컨텍스트(JMS 헤더와 같은 프로토콜 헤더, 계정 ID와 같은 사용자 컨텍스트 포함)를 전파합니다. 컨텍스트 서비스는 API 및 구성 가능한 설정 세트를 제공합니다.
컨텍스트 서비스 전파가 양방향이면, 응답 컨텍스트는 항상 현재 컨텍스트를 겹쳐씁니다. 하나의 SCA 컴포넌트에서 또 다른 컴포넌트로 호출 실행 시, 응답은 다른 컨텍스트를 포함합니다. 서비스 컴포넌트는 수신 컨텍스트를 가지지만, 다른 서비스 호출 시 다른 서비스가 원래의 전송 컨텍스트를 겹쳐씁니다. 응답 컨텍스트는 새 컨텍스트가 됩니다.
컨텍스트 서비스 전파가 단방향이면, 원래의 컨텍스트는 동일하게 남습니다.
컨텍스트 서비스의 라이프 사이클은 호출과 연관됩니다. 요청은 연관된 컨텍스트와 해당 특정 요청의 처리에 컨텍스트가 속한 라이프 사이클을 갖습니다. 해당 요청 처리가 완료되면, 해당 컨텍스트의 라이프 사이클이 끝납니다.
//Import the necessary classes; import com.ibm.bpm.context.ContextService; import com.ibm.websphere.sca.ServiceManager; import com.ibm.bpm.context.cobo.ContextObject; import com.ibm.bpm.context.cobo.ContextObjectFactory; import com.ibm.bpm.context.cobo.HeaderInfoType; import com.ibm.bpm.context.cobo.UserDefinedContextType; //Locate ContextService; ContextService contextService = (ContextService)ServiceManager.INSTANCE.locateService ("com/ibm/bpm/context/ContextService"); // Get header info HeaderInfo headerInfo = contextService.getHeaderInfo(); // Get user defined context in current execution context UserDefinedContextType userDefinedContext = contextService.getUserDefinedContext(); if(userDefinedContext == null){ // create a new context if context is null userDefinedContext = ContextObjectFactory.eINSTANCE.createUserDefinedContextType() } // Do some modification to header info and userDefinedContext // Set user defined context back to the current execution context. contextService.setUserDefinedContext(userDefinedContext); // Set header info back to the current execution context. contextService.setHeaderInfo(headerInfo);
컨텍스트 서비스에는 바인딩 동작을 지시하는 테이블과 구성 가능한 규칙이 있습니다. 자세한 정보는 참조 섹션에서 사용 가능한 생성 API 및 SPI 문서를 참조하십시오. WebSphere® Integration Developer를 개발하는 동안, 가져오기-내보내기 특성에 컨텍스트 서비스를 설정할 수 있습니다. 자세한 정보는 WebSphere® Integration Developer Information Center에서 가져오기 및 내보내기 바인딩 정보를 참조하십시오.