Skip to content

Instantly share code, notes, and snippets.

View estebanroblesluna's full-sized avatar

Esteban Robles Luna estebanroblesluna

View GitHub Profile
public class HibernateSessionAdvice {
private static Log logger = LogFactory.getLog(HibernateSessionAdvice.class);
public static final String DEFAULT_SESSION_FACTORY_BEAN_NAME = "sessionFactory";
private String sessionFactoryBeanName = DEFAULT_SESSION_FACTORY_BEAN_NAME;
private boolean singleSession = true;
private FlushMode flushMode = FlushMode.MANUAL;
private SessionFactory sessionFactory;
public class CloseHibernateSessionMP implements MessageProcessor {
private HibernateSessionAdvice advice;
public MuleEvent process(MuleEvent event) throws MuleException {
advice.closeSession();
return event;
}
public HibernateSessionAdvice getAdvice() {
return advice;
public class OpenHibernateSessionMP implements MessageProcessor {
private HibernateSessionAdvice advice;
public MuleEvent process(MuleEvent event) throws MuleException {
advice.openSession();
return event;
}
public HibernateSessionAdvice getAdvice() {
return advice;
<flow name="hibernateFlow">
<http:inbound-endpoint address="${hibernateFlow}" exchange-pattern="request-response">
<http:body-to-parameter-map-transformer/>
</http:inbound-endpoint>
...
<component>
<method-entry-point-resolver>
<include-entry-point method="methodA"/>
<mulexml:jaxb-context name="jaxbContext" packageNames="com.democompany.models.transactions"/>
<flow name="validateXML">
<vm:inbound-endpoint path="in" />
<mulexml:jaxb-xml-to-object-transformer name="XmlToTrade" jaxbContext-ref="jaxbContext"/>
<enricher target="#[header:INVOCATION:validationResult]">
<absoluterule:validation ruleSetClasses="com.democompany.rules.transactionvalidation.RuleSetTransactionRules" />
</enricher>
<flow name="sendToServer">
<http:inbound-endpoint address="http://localhost:1789/receiveRequest" exchange-pattern="request-response" />
<http:body-to-parameter-map-transformer />
<expression-transformer>
<return-argument evaluator="map-payload" expression="description" />
</expression-transformer>
<!-- Add attachment.xml as an attachment to be sent to the WS -->
public class R1 implements IValidationRule {
private Set<String> standingorderEtc;
...
public boolean validate(Transaction context) throws Exception {
Transaction current = context;
if (standingorderEtc.contains(current.getType())) {
return current.getAmount().compareTo(BigDecimal.valueOf(0)) < 0;
} else {
Context: Transaction
Validation Rule "r1"
If the type is one of 'STANDINGORDER', 'BANKFEE' then the amount is less than 0
Context: Transactions
Validation Rule "r2"
startBalance + the sum of transaction.amount = endBalance
Context: Transactions
Validation Rule "r3"
<expression-transformer>
<return-argument evaluator="header" expression="INVOCATION:cxf_attachments" />
</expression-transformer>
<expression-transformer>
<return-argument evaluator="groovy" expression="payload.iterator().next().getDataHandler().getContent()" />
</expression-transformer>
<http:inbound-endpoint address="http://localhost:1234/webServiceUrl" exchange-pattern="request-response">
<cxf:jaxws-service serviceClass="com.WebService">
<cxf:inInterceptors>
<spring:bean class="org.mule.module.cxf.support.CopyAttachmentInInterceptor"/>
</cxf:inInterceptors>
</cxf:jaxws-service>
</http:inbound-endpoint>