001 // Copyright 2007 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.hivemind.service; 016 017 /** 018 * Service that wires properties of object with services defined in the registry. 019 * Different strategies are available. The standard strategies are defined 020 * in {@link AutowiringStrategy}. 021 * 022 * @author Achim Huegen 023 */ 024 public interface Autowiring 025 { 026 /** 027 * Autowires the properties of <code>target</code> defined in <code>propertyNames</code>. 028 * All available strategies are tried until one strategy succeeds. 029 * @param target the target object whose properties should be wired 030 * @param propertyNames the properties to wire 031 * @return the wired target object 032 */ 033 public Object autowireProperties(Object target, String[] propertyNames); 034 035 /** 036 * Autowires all writable properties of <code>target</code>. 037 * All available strategies are tried until one strategy succeeds. 038 * @param target the target object whose properties should be wired 039 * @return the wired target object 040 */ 041 public Object autowireProperties(Object target); 042 043 /** 044 * Autowires the properties of <code>target</code> defined in <code>propertyNames</code> 045 * using a certain strategy. 046 * @param strategy name of the strategy to be used. Standard strategies are defined 047 * in {@link AutowiringStrategy} 048 * @param target the target object whose properties should be wired 049 * @param propertyNames the properties to wire 050 * @return the wired target object 051 */ 052 public Object autowireProperties(String strategy, Object target, String[] propertyNames); 053 054 /** 055 * Autowires all writable properties of <code>target</code> using a certain strategy. 056 * @param strategy name of the strategy to be used. Standard strategies are defined 057 * in {@link AutowiringStrategy} 058 * @param target the target object whose properties should be wired 059 * @return the wired target object 060 */ 061 public Object autowireProperties(String strategy, Object target); 062 063 }