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 org.apache.camel.RuntimeCamelException; 020 021/** 022 * Represents a {@link BeanRepository} which may also be capable 023 * of binding beans to its repository. 024 */ 025public interface Registry extends BeanRepository { 026 027 /** 028 * Binds the bean to the repository (if possible). 029 * 030 * @param id the id of the bean 031 * @param bean the bean 032 * @throws RuntimeCamelException is thrown if binding is not possible 033 */ 034 default void bind(String id, Object bean) throws RuntimeCamelException { 035 bind(id, bean.getClass(), bean); 036 } 037 038 /** 039 * Binds the bean to the repository (if possible). 040 * <p/> 041 * Binding by id and type allows to bind multiple entries with the same 042 * id but with different type. 043 * 044 * @param id the id of the bean 045 * @param type the type of the bean to associate the binding 046 * @param bean the bean 047 * @throws RuntimeCamelException is thrown if binding is not possible 048 */ 049 void bind(String id, Class<?> type, Object bean) throws RuntimeCamelException; 050 051 /** 052 * Strategy to wrap the value to be stored in the registry. 053 * 054 * @param value the value 055 * @return the value to store 056 */ 057 default Object wrap(Object value) { 058 return value; 059 } 060 061}