Coverage Report - org.apache.camel.bam.processor.JpaBamProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
JpaBamProcessor
77% 
100% 
0
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.camel.bam.processor;
 18  
 
 19  
 import org.apache.camel.Exchange;
 20  
 import org.apache.camel.Expression;
 21  
 import org.apache.camel.Processor;
 22  
 import org.apache.camel.bam.model.ActivityState;
 23  
 import org.apache.camel.bam.model.ProcessInstance;
 24  
 import org.apache.camel.bam.rules.ActivityRules;
 25  
 import org.apache.commons.logging.Log;
 26  
 import org.apache.commons.logging.LogFactory;
 27  
 import org.springframework.orm.jpa.JpaTemplate;
 28  
 import org.springframework.transaction.support.TransactionTemplate;
 29  
 
 30  
 /**
 31  
  * A concrete {@link Processor} for working on
 32  
  * <a href="http://activemq.apache.org/camel/bam.html">BAM</a> which uses JPA as the persistence and uses the
 33  
  * {@link ProcessInstance} entity to store the process information.
 34  
  *
 35  
  * @version $Revision: $
 36  
  */
 37  1
 public class JpaBamProcessor extends JpaBamProcessorSupport<ProcessInstance> {
 38  1
     private static final transient Log log = LogFactory.getLog(JpaBamProcessor.class);
 39  
 
 40  
     public JpaBamProcessor(TransactionTemplate transactionTemplate, JpaTemplate template, Expression<Exchange> correlationKeyExpression, ActivityRules activityRules) {
 41  0
         super(transactionTemplate, template, correlationKeyExpression, activityRules);
 42  0
     }
 43  
 
 44  
     public JpaBamProcessor(TransactionTemplate transactionTemplate, JpaTemplate template, Expression<Exchange> correlationKeyExpression, ActivityRules activityRules, Class<ProcessInstance> entitytype) {
 45  3
         super(transactionTemplate, template, correlationKeyExpression, activityRules, entitytype);
 46  3
     }
 47  
 
 48  
     protected void processEntity(Exchange exchange, ProcessInstance process) throws Exception {
 49  1
         if (log.isDebugEnabled()) {
 50  0
             log.debug("Processing process instance: " + process);
 51  
         }
 52  
 
 53  
         // lets force the lazy creation of this activity
 54  1
         ActivityRules rules = getActivityRules();
 55  1
         ActivityState state = process.getOrCreateActivityState(rules);
 56  
 
 57  1
         state.processExchange(rules, new ProcessContext(exchange, rules, state));
 58  
 
 59  1
         rules.getProcessRules().processExchange(exchange, process);
 60  1
     }
 61  
 }