/
2005-02-14-issue-with-servicegroup-in-edra-11.html
19 lines (16 loc) · 9.89 KB
/
2005-02-14-issue-with-servicegroup-in-edra-11.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
---
layout: post
title: Issue with ServiceGroup in EDRA 1.1
published: true
meta: {}
tags:
- Shadowfax
type: post
status: publish
---
<P>EDRA (Shadowfax) has a cool feature called <STRONG>ServiceGroup</STRONG>. This allows you to group services in a logical group and has a pipeline defined that uses the Service Group. An example of usage would be creating a service group for transactional service actions and another service group for non-transactional ones (example of Wake Jens from Volvo IT).</P>
<P>This nice feature has an issue in EDRA 1.1 so I decided to go deep into it. I found that there was a problem in the Configuration Validation which didn't take into account this service's group. To make the long story short, as we have the source code of EDRA here are the methods I've changed (in bold) on the file <EM>ConfigValidator.cs </EM>to make the ServiceGroups work (download <A HREF="/blogs/matiaswoloski/content/binary/ConfigValidator.zip">ConfigValidator.zip (61.44 KB)</A>):</P>
<P>1. <STRONG>ValidateBusinessActionNames</STRONG></P>
<P><SPAN><SPAN><SPAN>private</SPAN> <SPAN>bool</SPAN> ValidateBusinessActionNames(StringBuilder report)<BR>{<BR> <SPAN>string</SPAN> serviceActionName <SPAN>=</SPAN> <SPAN>null</SPAN>;<BR> <SPAN>string</SPAN> pipelineName <SPAN>=</SPAN> <SPAN>null</SPAN>;<BR> <SPAN>bool</SPAN> baServiceActionFound;<BR> <SPAN>bool</SPAN> result <SPAN>=</SPAN> <SPAN>true</SPAN>;<BR><BR> IDictionaryEnumerator businessActionEnumerator <SPAN>=</SPAN> _businessActDefSettings.BusinessActions.GetEnumerator(); <BR> <SPAN>while</SPAN> ( businessActionEnumerator.MoveNext() )<BR> {<BR> BusinessActionSettings baSettings <SPAN>=</SPAN> (BusinessActionSettings)businessActionEnumerator.Value;<BR> <BR> <SPAN>// Checking if the current business action specified in the configuration</SPAN><BR> <SPAN>// is a compenstae business action or not. The checks for service interface</SPAN><BR> <SPAN>// service implementation pipeline should be done only if the the business</SPAN><BR> <SPAN>// action is not specified as compensate business action for any of the existing</SPAN><BR> <SPAN>// business actions.</SPAN><BR> <SPAN>if</SPAN> (IsCompensateBusinessAction(baSettings.Name))<BR> {<BR> <SPAN>continue</SPAN>;<BR> }<BR><BR> IDictionaryEnumerator pipelineEnumerator <SPAN>=</SPAN> _pipelineDefSettings.ServiceInterfacePipelines.GetEnumerator();<BR> baServiceActionFound <SPAN>=</SPAN> <SPAN>false</SPAN>;<BR> <SPAN>while</SPAN> ( pipelineEnumerator.MoveNext() )<BR> {<BR> ServiceInterfacePipelineConfig pipelineCfg <SPAN>=</SPAN> (ServiceInterfacePipelineConfig)pipelineEnumerator.Value;<BR> serviceActionName <SPAN>=</SPAN> pipelineCfg.ServiceName; <BR> pipelineName <SPAN>=</SPAN> pipelineCfg.Name;<BR><BR> <STRONG> <SPAN>bool</SPAN> isInServiceGroup <SPAN>=</SPAN> <SPAN>false</SPAN>;<BR> <SPAN>if</SPAN> ( pipelineCfg.ServiceGroup !<SPAN>=</SPAN> <SPAN>null</SPAN> && pipelineCfg.ServiceGroup !<SPAN>=</SPAN> String.Empty ) <BR> {<BR> <SPAN>// get the service group for the current pipeline config and check that the service group contains the business action</SPAN><BR> ServiceGroupConfig serviceGroup <SPAN>=</SPAN> (ServiceGroupConfig)PipelinesConfig.Config.ServiceGroups[ pipelineCfg.ServiceGroup ];<BR> isInServiceGroup <SPAN>=</SPAN> serviceGroup.Services.Contains( baSettings.Name.Trim() );<BR> }<BR></STRONG> <BR> <SPAN>if</SPAN>( (String.Compare(baSettings.Name.Trim(), serviceActionName.Trim(), <SPAN>true</SPAN>) == 0 ) || ( serviceActionName == <SPAN>"*"</SPAN> ) || ( <STRONG>isInServiceGroup</STRONG> ) )<BR> {<BR> baServiceActionFound <SPAN>=</SPAN> <SPAN>true</SPAN>;<BR> <SPAN>break</SPAN>;<BR> }<BR> }<BR> <SPAN>if</SPAN> ( baServiceActionFound == <SPAN>false</SPAN> )<BR> {<BR> result &= <SPAN>false</SPAN>;<BR> report.Append(Resource.ResourceManager.FormatMessage(Resource.MessageKey.ServiceInterfacePipelineMissingForBAErrMsg, baSettings.Name));<BR> <SPAN>break</SPAN>;<BR> }<BR><BR><BR> pipelineEnumerator <SPAN>=</SPAN> _pipelineDefSettings.ServiceImplementationPipelines.GetEnumerator();<BR> baServiceActionFound <SPAN>=</SPAN> <SPAN>false</SPAN>;<BR> <SPAN>while</SPAN> ( pipelineEnumerator.MoveNext() )<BR> {<BR> ServiceImplementationPipelineConfig pipelineCfg <SPAN>=</SPAN> (ServiceImplementationPipelineConfig)pipelineEnumerator.Value;<BR> serviceActionName <SPAN>=</SPAN> pipelineCfg.ServiceName; <BR> pipelineName <SPAN>=</SPAN> pipelineCfg.Name;<BR><BR> <STRONG> <SPAN>bool</SPAN> isInServiceGroup <SPAN>=</SPAN> <SPAN>false</SPAN>;<BR> <SPAN>if</SPAN> ( pipelineCfg.ServiceGroup !<SPAN>=</SPAN> <SPAN>null</SPAN> && pipelineCfg.ServiceGroup !<SPAN>=</SPAN> String.Empty ) <BR> {<BR> ServiceGroupConfig serviceGroup <SPAN>=</SPAN> (ServiceGroupConfig)PipelinesConfig.Config.ServiceGroups[ pipelineCfg.ServiceGroup ];<BR> isInServiceGroup <SPAN>=</SPAN> serviceGroup.Services.Contains( baSettings.Name.Trim() );<BR> }<BR></STRONG><BR> <SPAN>if</SPAN>( (String.Compare(baSettings.Name.Trim(), serviceActionName.Trim(), <SPAN>true</SPAN>) == 0 ) || ( serviceActionName == <SPAN>"*"</SPAN> ) || ( <STRONG>isInServiceGroup</STRONG> ) )<BR> {<BR> baServiceActionFound <SPAN>=</SPAN> <SPAN>true</SPAN>;<BR> }<BR> }<BR> <SPAN>if</SPAN> ( baServiceActionFound == <SPAN>false</SPAN> )<BR> {<BR> result &= <SPAN>false</SPAN>;<BR> report.Append(Resource.ResourceManager.FormatMessage(Resource.MessageKey.ServiceImplPipelineMissingForBAErrMsg, baSettings.Name));<BR> <SPAN>break</SPAN>;<BR> }<BR> }<BR> <SPAN>return</SPAN>(result);<BR>}</SPAN></SPAN></P>
<P><SPAN><FONT face="Verdana" color="#003300" size="2">2. <STRONG>ValidateImplPipelines</STRONG></FONT></SPAN></P><SPAN>
<P><SPAN><SPAN>private</SPAN> <SPAN>bool</SPAN> ValidateImplPipelines(StringBuilder report, <SPAN>string</SPAN> serviceActionName)<BR>{<BR> <SPAN>bool</SPAN> result <SPAN>=</SPAN> <SPAN>true</SPAN>;<BR> BusinessActionSettingCollection baSettingCollection <SPAN>=</SPAN> _businessActDefSettings.BusinessActions;<BR><BR> <SPAN>foreach</SPAN>(DictionaryEntry entry <SPAN>in</SPAN> _pipelineDefSettings.ServiceImplementationPipelines )<BR> {<BR> ServiceImplementationPipelineConfig config <SPAN>=</SPAN> (ServiceImplementationPipelineConfig)entry.Value;<BR> <SPAN>if</SPAN> ( ( String.Compare(config.ServiceName.Trim(), serviceActionName.Trim(), <SPAN>true</SPAN>) == 0 ) || (config.ServiceName.Trim() == <SPAN>"*"</SPAN>) )<BR> {<BR> result &= ValidateHandlers(report, config, JoinPoint.ServiceImplementation);<BR> <BR> <SPAN>// Checking if the service implementation pipeline is default</SPAN><BR> <SPAN>if</SPAN> ( config.ServiceName.Trim() !<SPAN>=</SPAN> <SPAN>"*"</SPAN> )<BR> {<BR> <SPAN>// if a service group was configured, check that each service action on the servicegroup has a corresponding BA</SPAN><BR> <STRONG><SPAN>if</SPAN> ( config.ServiceGroup.Trim() !<SPAN>=</SPAN> String.Empty ) <BR> {<BR> ServiceGroupConfig serviceGroup <SPAN>=</SPAN> (ServiceGroupConfig)PipelinesConfig.Config.ServiceGroups[ config.ServiceGroup ];<BR> <SPAN>foreach</SPAN>( <SPAN>string</SPAN> service <SPAN>in</SPAN> serviceGroup.Services ) <BR> {<BR> BusinessActionSettings baSettings <SPAN>=</SPAN> baSettingCollection[ service ];<BR> result &= ValidateAssemblyInfo(report, baSettings.TypeName, <SPAN>"business action"</SPAN>);<BR> result &= ValidateBusinessActionInvocationModes(report, baSettings);<BR> }<BR> } <BR> <SPAN>else</SPAN> <BR></STRONG> {<BR> BusinessActionSettings baSettings <SPAN>=</SPAN> baSettingCollection[config.ServiceName];<BR> result &= ValidateAssemblyInfo(report, baSettings.TypeName, <SPAN>"business action"</SPAN>);<BR> result &= ValidateBusinessActionInvocationModes(report, baSettings);<BR> } <BR> }<BR> <SPAN>break</SPAN>;<BR> }<BR> }<BR> <SPAN>return</SPAN>(result);<BR>}</SPAN><SPAN><SPAN><BR></SPAN></P></SPAN></SPAN>