View Javadoc

1   /*
2    * Copyright 2006-2016 The JGUIraffe Team.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License")
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.jguiraffe.di;
17  
18  /**
19   * <p>
20   * Definition of an interface for describing a dependency to another
21   * <code>{@link BeanProvider}</code> in an abstract way.
22   * </p>
23   * <p>
24   * <code>BeanProvider</code>s often depend on other providers, e.g. some
25   * properties of the bean to be created need to be initialized with other beans.
26   * There are different ways of defining such dependencies: by specifying the
27   * name of the dependent bean, by specifying its class, etc. This interface
28   * provides a generic way of defining dependencies. It has a
29   * <code>resolve()</code> method that can be implemented in a suitable way.
30   * </p>
31   *
32   * @author Oliver Heger
33   * @version $Id: Dependency.java 205 2012-01-29 18:29:57Z oheger $
34   */
35  public interface Dependency
36  {
37      /**
38       * Resolves this dependency starting from the specified
39       * <code>BeanStore</code>. A concrete implementation has to search for the
40       * <code>BeanProvider</code> it depends on. If necessary, the given bean
41       * store's parent has to be searched recursively. The <code>DependencyProvider</code>
42       * can be used for querying further information about the current context,
43       * e.g. for resolving classes using predefined class loaders.
44       *
45       * @param store the current bean store
46       * @param depProvider the dependency provider
47       * @return the resolved bean
48       * @throws InjectionException if resolving of the dependency fails
49       */
50      BeanProvider resolve(BeanStore store, DependencyProvider depProvider);
51  }