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.runtimecatalog; 018 019import java.net.URISyntaxException; 020import java.util.Map; 021 022import org.apache.camel.StaticService; 023 024/** 025 * Runtime based CamelCatalog which are included in camel-core that can provided limit CamelCatalog capabilities 026 */ 027public interface RuntimeCamelCatalog extends StaticService { 028 029 /** 030 * Returns the component information as JSon format. 031 * 032 * @param name the component name 033 * @return component details in JSon 034 */ 035 String componentJSonSchema(String name); 036 037 /** 038 * Returns the data format information as JSon format. 039 * 040 * @param name the data format name 041 * @return data format details in JSon 042 */ 043 String dataFormatJSonSchema(String name); 044 045 /** 046 * Returns the language information as JSon format. 047 * 048 * @param name the language name 049 * @return language details in JSon 050 */ 051 String languageJSonSchema(String name); 052 053 /** 054 * Returns the model information as JSon format. 055 * 056 * @param name the model name 057 * @return model details in JSon 058 */ 059 String modelJSonSchema(String name); 060 061 /** 062 * Parses the endpoint uri and constructs a key/value properties of each option 063 * 064 * @param uri the endpoint uri 065 * @return properties as key value pairs of each endpoint option 066 */ 067 Map<String, String> endpointProperties(String uri) throws URISyntaxException; 068 069 /** 070 * Parses the endpoint uri and constructs a key/value properties of only the lenient properties (eg custom options) 071 * <p/> 072 * For example using the HTTP components to provide query parameters in the endpoint uri. 073 * 074 * @param uri the endpoint uri 075 * @return properties as key value pairs of each lenient properties 076 */ 077 Map<String, String> endpointLenientProperties(String uri) throws URISyntaxException; 078 079 /** 080 * Validates the pattern whether its a valid time pattern. 081 * 082 * @param pattern the pattern such as 5000, 5s, 5sec, 4min, 4m30s, 1h, etc. 083 * @return <tt>true</tt> if valid, <tt>false</tt> if invalid 084 */ 085 boolean validateTimePattern(String pattern); 086 087 /** 088 * Validates the properties for the given scheme against component and endpoint 089 * 090 * @param scheme the endpoint scheme 091 * @param properties the endpoint properties 092 * @return validation result 093 */ 094 EndpointValidationResult validateProperties(String scheme, Map<String, String> properties); 095 096 /** 097 * Parses and validates the endpoint uri and constructs a key/value properties of each option. 098 * 099 * @param uri the endpoint uri 100 * @return validation result 101 */ 102 EndpointValidationResult validateEndpointProperties(String uri); 103 104 /** 105 * Parses and validates the endpoint uri and constructs a key/value properties of each option. 106 * <p/> 107 * The option ignoreLenientProperties can be used to ignore components that uses lenient properties. 108 * When this is true, then the uri validation is stricter but would fail on properties that are not part of the component 109 * but in the uri because of using lenient properties. 110 * For example using the HTTP components to provide query parameters in the endpoint uri. 111 * 112 * @param uri the endpoint uri 113 * @param ignoreLenientProperties whether to ignore components that uses lenient properties. 114 * @return validation result 115 */ 116 EndpointValidationResult validateEndpointProperties(String uri, boolean ignoreLenientProperties); 117 118 /** 119 * Parses and validates the endpoint uri and constructs a key/value properties of each option. 120 * <p/> 121 * The option ignoreLenientProperties can be used to ignore components that uses lenient properties. 122 * When this is true, then the uri validation is stricter but would fail on properties that are not part of the component 123 * but in the uri because of using lenient properties. 124 * For example using the HTTP components to provide query parameters in the endpoint uri. 125 * 126 * @param uri the endpoint uri 127 * @param ignoreLenientProperties whether to ignore components that uses lenient properties. 128 * @param consumerOnly whether the endpoint is only used as a consumer 129 * @param producerOnly whether the endpoint is only used as a producer 130 * @return validation result 131 */ 132 EndpointValidationResult validateEndpointProperties(String uri, boolean ignoreLenientProperties, boolean consumerOnly, boolean producerOnly); 133 134 /** 135 * Parses and validates the simple expression. 136 * <p/> 137 * <b>Important:</b> This requires having <tt>camel-core</tt> on the classpath 138 * 139 * @param simple the simple expression 140 * @return validation result 141 * @deprecated use {@link #validateSimpleExpression(ClassLoader, String)} 142 */ 143 @Deprecated 144 SimpleValidationResult validateSimpleExpression(String simple); 145 146 /** 147 * Parses and validates the simple expression. 148 * <p/> 149 * <b>Important:</b> This requires having <tt>camel-core</tt> on the classpath 150 * 151 * @param classLoader a custom classloader to use for loading the language from the classpath, or <tt>null</tt> for using default classloader 152 * @param simple the simple expression 153 * @return validation result 154 */ 155 SimpleValidationResult validateSimpleExpression(ClassLoader classLoader, String simple); 156 157 /** 158 * Parses and validates the simple predicate 159 * <p/> 160 * <b>Important:</b> This requires having <tt>camel-core</tt> on the classpath 161 * 162 * @param simple the simple predicate 163 * @return validation result 164 * @deprecated use {@link #validateSimplePredicate(ClassLoader, String)} 165 */ 166 @Deprecated 167 SimpleValidationResult validateSimplePredicate(String simple); 168 169 /** 170 * Parses and validates the simple predicate 171 * <p/> 172 * <b>Important:</b> This requires having <tt>camel-core</tt> on the classpath 173 * 174 * @param classLoader a custom classloader to use for loading the language from the classpath, or <tt>null</tt> for using default classloader 175 * @param simple the simple predicate 176 * @return validation result 177 */ 178 SimpleValidationResult validateSimplePredicate(ClassLoader classLoader, String simple); 179 180 /** 181 * Parses and validates the language as a predicate 182 * <p/> 183 * <b>Important:</b> This requires having <tt>camel-core</tt> and the language dependencies on the classpath 184 * 185 * @param classLoader a custom classloader to use for loading the language from the classpath, or <tt>null</tt> for using default classloader 186 * @param language the name of the language 187 * @param text the predicate text 188 * @return validation result 189 */ 190 LanguageValidationResult validateLanguagePredicate(ClassLoader classLoader, String language, String text); 191 192 /** 193 * Parses and validates the language as an expression 194 * <p/> 195 * <b>Important:</b> This requires having <tt>camel-core</tt> and the language dependencies on the classpath 196 * 197 * @param classLoader a custom classloader to use for loading the language from the classpath, or <tt>null</tt> for using default classloader 198 * @param language the name of the language 199 * @param text the expression text 200 * @return validation result 201 */ 202 LanguageValidationResult validateLanguageExpression(ClassLoader classLoader, String language, String text); 203 204 /** 205 * Returns the component name from the given endpoint uri 206 * 207 * @param uri the endpoint uri 208 * @return the component name (aka scheme), or <tt>null</tt> if not possible to determine 209 */ 210 String endpointComponentName(String uri); 211 212 /** 213 * Creates an endpoint uri in Java style from the information from the properties 214 * 215 * @param scheme the endpoint schema 216 * @param properties the properties as key value pairs 217 * @param encode whether to URL encode the returned uri or not 218 * @return the constructed endpoint uri 219 * @throws java.net.URISyntaxException is thrown if there is encoding error 220 */ 221 String asEndpointUri(String scheme, Map<String, String> properties, boolean encode) throws URISyntaxException; 222 223 /** 224 * Creates an endpoint uri in XML style (eg escape & as &l;) from the information from the properties 225 * 226 * @param scheme the endpoint schema 227 * @param properties the properties as key value pairs 228 * @param encode whether to URL encode the returned uri or not 229 * @return the constructed endpoint uri 230 * @throws java.net.URISyntaxException is thrown if there is encoding error 231 */ 232 String asEndpointUriXml(String scheme, Map<String, String> properties, boolean encode) throws URISyntaxException; 233 234}