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.spi; 018 019import java.util.List; 020 021import org.apache.camel.Consumer; 022import org.apache.camel.Service; 023 024/** 025 * A registry of all REST services running within the {@link org.apache.camel.CamelContext} which have been defined and created 026 * using the <a href="http://camel.apache.org/rest-dsl">Rest DSL</a>. 027 */ 028public interface RestRegistry extends Service { 029 030 /** 031 * Details about the REST service 032 */ 033 interface RestService { 034 035 /** 036 * Gets the consumer of the REST service 037 */ 038 Consumer getConsumer(); 039 040 /** 041 * Gets the state of the REST service (started, stopped, etc) 042 */ 043 String getState(); 044 045 /** 046 * Gets the absolute url to the REST service (baseUrl + uriTemplate) 047 */ 048 String getUrl(); 049 050 /** 051 * Gets the base url to the REST service 052 */ 053 String getBaseUrl(); 054 055 /** 056 * Gets the base path to the REST service 057 */ 058 String getBasePath(); 059 060 /** 061 * Gets the uri template 062 */ 063 String getUriTemplate(); 064 065 /** 066 * Gets the HTTP method (GET, POST, PUT etc) 067 */ 068 String getMethod(); 069 070 /** 071 * Optional details about what media-types the REST service accepts 072 */ 073 String getConsumes(); 074 075 /** 076 * Optional details about what media-types the REST service returns 077 */ 078 String getProduces(); 079 080 /** 081 * Optional detail about input binding to a FQN class name. 082 * <p/> 083 * If the input accepts a list, then <tt>List<class name></tt> is enclosed the name. 084 */ 085 String getInType(); 086 087 /** 088 * Optional detail about output binding to a FQN class name. 089 * <p/> 090 * If the output accepts a list, then <tt>List<class name></tt> is enclosed the name. 091 */ 092 String getOutType(); 093 094 /** 095 * Gets the id of the route this rest service will be using. 096 */ 097 String getRouteId(); 098 099 /** 100 * Optional description about this rest service. 101 */ 102 String getDescription(); 103 104 } 105 106 /** 107 * Adds a new REST service to the registry. 108 * 109 * @param consumer the consumer 110 * @param url the absolute url of the REST service 111 * @param baseUrl the base url of the REST service 112 * @param basePath the base path 113 * @param uriTemplate the uri template 114 * @param method the HTTP method 115 * @param consumes optional details about what media-types the REST service accepts 116 * @param produces optional details about what media-types the REST service returns 117 * @param inType optional detail input binding to a FQN class name 118 * @param outType optional detail output binding to a FQN class name 119 * @param routeId the id of the route this rest service will be using 120 * @param description optional description about the the service 121 */ 122 void addRestService(Consumer consumer, String url, String baseUrl, String basePath, String uriTemplate, String method, String consumes, String produces, 123 String inType, String outType, String routeId, String description); 124 125 /** 126 * Removes the REST service from the registry 127 * 128 * @param consumer the consumer 129 */ 130 void removeRestService(Consumer consumer); 131 132 /** 133 * List all REST services from this registry. 134 * 135 * @return all the REST services 136 */ 137 List<RestService> listAllRestServices(); 138 139 /** 140 * Number of rest services in the registry. 141 * 142 * @return number of rest services in the registry. 143 */ 144 int size(); 145 146}