Page 1 of 1

How does the core project get these injection working?

Posted: Thu Jul 17, 2014 6:31 am
by daniel_locious
Hi guys,

I am a newbee on spring; tried very hard to look for the entry point for the payment processor or configureService (in "core" project), just don't really get how does it work.

Take this piece in applicationContext.xml as an example:
<bean class="org.broadleafcommerce.common.extensibility.context.merge.LateStageMergeBeanPostProcessor">
<property name="collectionRef" value="mySamplePaymentProcessors"/>
<property name="targetRef" value="blDialectProcessors"/>
</bean>
this magic class "LateStageMergeBeanPostProcessor" seems pointing the payment processor to blDialectProcessors, but I couldn't find where was blDialectProcessors used; the only assumption is blDialect which is used in thymeleaf SpringTemplateEngine. Then how does it call the processors?

Another question:
<bean class="com.icearn.sample.vendor.nullPaymentGateway.service.payment.NullPaymentGatewayType"/>
what's the purpose of this bean? Do we need to explicitely inject it here?

Thank you for your time to read this; If you would like to answer either of the questions, do appreciate your answer.

Cheers,

Dan

Re: How does the core project get these injection working?

Posted: Tue Jul 29, 2014 2:10 pm
by phillipuniverse
"processor" here is a little loosely defined. In this context, it does definitely mean Thymeleaf processor. A Thymeleaf processor is analogous to a JSP tag if you are familiar with Java web development in general. If not, just think of it as a view-layer invocation to actually do things in Java code.

In this case, this sample payment processor is really a Thymeleaf processor and will modify the checkout form to obtain the URL that the form should post to. The form in question is generated via the OnePageCheckoutProcessor.

The purpose of that gateway type bean does nothing more than essentially register the NULL_GATEWAY and NULL_HOSTED_GATEWAY as valid payment gateway types. Specifying it as a bean in that way ensures that the class will be loaded and the types will be added to the PaymentGatewayType static map. This gets translated to OrderPayment.getGatewayType().