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 <a
 32  
  * href="http://activemq.apache.org/camel/bam.html">BAM</a> which uses JPA as
 33  
  * the persistence and uses the {@link ProcessInstance} entity to store the
 34  
  * process information.
 35  
  * 
 36  
  * @version $Revision: $
 37  
  */
 38  6
 public class JpaBamProcessor extends JpaBamProcessorSupport<ProcessInstance> {
 39  2
     private static final transient Log LOG = LogFactory.getLog(JpaBamProcessor.class);
 40  
 
 41  
     public JpaBamProcessor(TransactionTemplate transactionTemplate, JpaTemplate template, Expression<Exchange> correlationKeyExpression, ActivityRules activityRules) {
 42  0
         super(transactionTemplate, template, correlationKeyExpression, activityRules);
 43  0
     }
 44  
 
 45  
     public JpaBamProcessor(TransactionTemplate transactionTemplate, JpaTemplate template, Expression<Exchange> correlationKeyExpression, 
 46  
                            ActivityRules activityRules, Class<ProcessInstance> entitytype) {
 47  4
         super(transactionTemplate, template, correlationKeyExpression, activityRules, entitytype);
 48  4
     }
 49  
 
 50  
     protected void processEntity(Exchange exchange, ProcessInstance process) throws Exception {
 51  6
         if (LOG.isDebugEnabled()) {
 52  0
             LOG.debug("Processing process instance: " + process);
 53  
         }
 54  
 
 55  
         // lets force the lazy creation of this activity
 56  6
         ActivityRules rules = getActivityRules();
 57  6
         ActivityState state = process.getOrCreateActivityState(rules);
 58  
 
 59  6
         state.processExchange(rules, new ProcessContext(exchange, rules, state));
 60  
 
 61  6
         rules.getProcessRules().processExchange(exchange, process);
 62  6
     }
 63  
 }