Portlet Factory, Version 6.1.2
Registry mapping file selectors
Selectors evaluate to either true or false. If the conditions exist that make a selector's criteria evaluate to true, then the mapping declared inside the selector is used. Consider this example:
<ForService name="services/myDataServices" when="regen-time"> <UseStub /> </ForService>The ForService selector accepts an attribute called name. If the value of the name attribute matches the model ID of the Service Provider referenced in the Service Consumer model, then the mapping gets applied. The model ID is derived from the full path and filename of the Service Provider model. A full path and filename of a Service Provider model looks like this: WEB-INF\models\subfolders\...\filename.model. The model ID omits the leading WEB-INF\models\ and the .model at the end of the filename. It also reverses the slashes. Therefore, a model located at WEB-INF\models\services\myDataServices.model has a model ID of services/myDataServices.
There are other selectors that can be used in Service Mapping Registry files.
- ForAllServices
- Always evaluates to true unless additional attributes are supplied. For example,
<ForAllServices when="regen-time"> <UseStub /> </ForAllServices>evaluates to true at regeneration time but false at runtime.- ForServiceMatching
- Uses a regular expression (RegEx) pattern matching value in an attribute named pattern. Service Providers whose model IDs match the pattern get replaced by the Service Providers declared in the mapping portion of the Selector. For example,
<ForServiceMatching pattern="_testing"> <ModifyName pattern="_testing" replacement="_production" /> </ForServiceMatching>Assuming a naming convention of Service Provider models that includes the substrings _testing and _production, this construct would swap all Service Providers whose model IDs contained the substring _testing and replace them with the substring _production. The actual models would not be changed, but any attempt to use a _testing Service Provider would cause the corresponding _production Service Provider to be used instead.
- IfParameterEquals
- Relies on mapping parameters declared in the Service Consumer builder call of the application model. This construct designates which Service Provider to use when certain name-value pairs exist in the Service Consumer model. For example, the construct below states for any attempt to use the services/myDataServices provider model, check to see if there is a mapping parameter called mode having a value of testing or production and swap the Service Provider accordingly. If no mapping parameter exists or if the value of the parameter does not match either value, then the services/myDataServices Service Provider model should be used.
<ForService name="services/myDataServices"> <IfParameterEquals name="mode" value="testing"> <UseService name="services/myDataServices_testing" /> </IfParameterEquals> <IfParameterEquals name="mode" value="production"> <UseService name="services/myDataServices_production" /> </IfParameterEquals> <UseService name="services/myDataServices" /> </ForService>Parent topic: Using data services
Library | Support |