View Javadoc
1   /*
2    * Copyright 2009 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.platform.camel.core.model;
17  
18  import org.apache.camel.Exchange;
19  import org.apache.camel.Processor;
20  import org.apache.camel.spi.Metadata;
21  import org.apache.camel.spi.RouteContext;
22  
23  import javax.xml.bind.annotation.*;
24  
25  /**
26   * @author Martin Krasser
27   */
28  @Metadata(label = "ipf,eip")
29  @XmlRootElement(name = "audit")
30  @XmlAccessorType(XmlAccessType.FIELD)
31  public class AuditDefinition extends DelegateDefinition {
32  
33      @XmlTransient
34      private Processor auditProcessor;
35      @XmlAttribute
36      private String auditProcessorBeanName;
37      
38      public AuditDefinition() {
39          auditProcessor = new Noop();
40      }
41      
42      /**
43       * @param auditProcessor the auditProcessor to set
44       */
45      public void setAuditProcessor(Processor auditProcessor) {
46          this.auditProcessor = auditProcessor;
47      }
48      
49      /**
50       * @param auditProcessorBeanName the auditProcessorBeanName to set
51       */
52      public void setAuditProcessorBeanName(String auditProcessorBeanName) {
53          this.auditProcessorBeanName = auditProcessorBeanName;
54      }
55      
56      @Override
57      protected Processor doCreateDelegate(RouteContext routeContext) {
58          if (auditProcessorBeanName != null) {
59              auditProcessor = routeContext.lookup(auditProcessorBeanName, Processor.class);
60          }
61          return auditProcessor;
62      }
63  
64      private static class Noop implements Processor {
65  
66          @Override
67          public void process(Exchange exchange) throws Exception {
68          }
69          
70      }
71      
72  }