001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel.model.cloud; 018 019import javax.xml.bind.annotation.XmlAccessType; 020import javax.xml.bind.annotation.XmlAccessorType; 021import javax.xml.bind.annotation.XmlAttribute; 022import javax.xml.bind.annotation.XmlRootElement; 023import javax.xml.bind.annotation.XmlTransient; 024 025import org.apache.camel.CamelContext; 026import org.apache.camel.cloud.ServiceFilter; 027import org.apache.camel.spi.Metadata; 028 029@Metadata(label = "routing,cloud,service-filter") 030@XmlRootElement(name = "customServiceFilter") 031@XmlAccessorType(XmlAccessType.FIELD) 032public class CustomServiceCallServiceFilterConfiguration extends ServiceCallServiceFilterConfiguration { 033 @XmlAttribute(name = "ref") 034 private String serviceFilterRef; 035 @XmlTransient 036 private ServiceFilter serviceFilter; 037 038 public CustomServiceCallServiceFilterConfiguration() { 039 this(null); 040 } 041 042 public CustomServiceCallServiceFilterConfiguration(ServiceCallDefinition parent) { 043 super(parent, "custom-service-filter"); 044 } 045 046 // ************************************************************************* 047 // Properties 048 // ************************************************************************* 049 050 public String getServiceFilterRef() { 051 return serviceFilterRef; 052 } 053 054 /** 055 * Reference of a ServiceFilter 056 */ 057 public void setServiceFilterRef(String serviceFilterRef) { 058 this.serviceFilterRef = serviceFilterRef; 059 } 060 061 public ServiceFilter getServiceFilter() { 062 return serviceFilter; 063 } 064 065 /** 066 * Set the ServiceFilter 067 */ 068 public void setServiceFilter(ServiceFilter serviceFilter) { 069 this.serviceFilter = serviceFilter; 070 } 071 072 073 // ************************************************************************* 074 // Fluent API 075 // ************************************************************************* 076 077 /** 078 * Reference of a ServiceFilter 079 */ 080 public CustomServiceCallServiceFilterConfiguration serviceFilter(String serviceFilter) { 081 setServiceFilterRef(serviceFilter); 082 return this; 083 } 084 085 /** 086 * Set the ServiceFilter 087 */ 088 public CustomServiceCallServiceFilterConfiguration serviceFilter(ServiceFilter serviceFilter) { 089 setServiceFilter(serviceFilter); 090 return this; 091 } 092 093 // ************************************************************************* 094 // Factory 095 // ************************************************************************* 096 097 @Override 098 public ServiceFilter newInstance(CamelContext camelContext) throws Exception { 099 ServiceFilter answer = serviceFilter; 100 if (serviceFilterRef != null) { 101 answer = camelContext.getRegistry().lookupByNameAndType(serviceFilterRef, ServiceFilter.class); 102 } 103 104 return answer; 105 } 106}