View Javadoc
1   /*
2    * Copyright 2008 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.spi.Metadata;
19  import org.apache.camel.spi.RouteContext;
20  import org.openehealth.ipf.commons.core.modules.api.Renderer;
21  import org.openehealth.ipf.platform.camel.core.adapter.ProcessorAdapter;
22  import org.openehealth.ipf.platform.camel.core.adapter.RendererAdapter;
23  
24  import javax.xml.bind.annotation.*;
25  
26  /**
27   * @author Martin Krasser
28   */
29  @Metadata(label = "ipf,eip,transformation")
30  @XmlRootElement(name = "render")
31  @XmlAccessorType(XmlAccessType.FIELD)
32  public class RendererAdapterDefinition extends ProcessorAdapterDefinition {
33  
34      @XmlTransient
35      private Renderer renderer;
36      @XmlAttribute
37      private String rendererBean;
38  
39      public RendererAdapterDefinition() {
40      }
41  
42      public RendererAdapterDefinition(Renderer renderer) {
43          this.renderer = renderer;
44      }
45      
46      public RendererAdapterDefinition(String rendererBean) {
47          this.rendererBean = rendererBean;
48      }
49      
50      @Override
51      public String toString() {
52          return "RendererAdapter[" + getOutputs() + "]";
53      }
54  
55      @Override
56      public String getShortName() {
57          return "rendererAdapter";
58      }
59  
60      @Override
61      protected ProcessorAdapter doCreateProcessor(RouteContext routeContext) {
62          if (rendererBean != null) {
63              renderer = routeContext.lookup(rendererBean, Renderer.class);
64          }
65          return new RendererAdapter(renderer);
66      }
67  
68  }