jpos / jPOS

jPOS Project
http://jpos.org
GNU Affero General Public License v3.0
607 stars 460 forks source link

Add regular expression support to Switch participant #309

Open alcarraz opened 4 years ago

alcarraz commented 4 years ago

Switch participant is described in jPOS programmer's guide section 9.8.1.

Motivation

Switch participant is a highly performant groups selector, but it lacks the ability of handling multiple different but similar entries (e.g. with a common prefix) that should route to the same groups.

I'm writing this issue to have feedback about the best way of implementing this.

I see two options at a first glance:

  1. Use some prefix to distinguish between regex properties than common ones, like:
    <property name="re:100\.30(\.[0-9]{4})?" value="xxx prepareresponse logit close sendresponse"/>
  2. Make Switch implement XMLConfigurable and have something similar to what is done in SelectDestination but just for regexes. e.g.:
    <participant class="org.jpos.transaction.participant.Switch"
    logger="Q2" realm="Switch">
    <property name="100.30"
    value="balanceinquiry prepareresponse logit close sendresponse" />
    <regex groups="xxx prepareresponse logit close sendresponse">100\.30\.[0-9]{4}</regex> <!--e.g.: for generic reason code handling-->

    In both cases direct properties would have precedence over regex ones, to maintain the efficiency of look up table, if the name is not present as property then we would look iterate over regex in order of definition.

So it behaves efficiently for common transactions but you have the option of leave open cases where there are too many (and infrequent) combinations to list them all one by one, in particular for combinations of function code x reason code.

I'm highly inclined to option 2 but would like better ideas for the syntax.

ar commented 4 years ago

I like the latter, but the former is so easy that perhaps it's the way to go. Now the question, just re: as a prefix or regexp: ?

alcarraz commented 4 years ago

Can we settle in regex: after java.util.regex package?

I'll take this issue if you agree.