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.impl;
17
18 import java.util.List;
19
20 import net.sf.jguiraffe.di.Dependency;
21 import net.sf.jguiraffe.di.DependencyProvider;
22
23 /**
24 * <p>
25 * Definition of an interface for objects that perform some kind of method
26 * invocation.
27 * </p>
28 * <p>
29 * This interface allows handling of different invocations (e.g. constructor
30 * invocation, method invocation, etc.) in a generic way. It defines an
31 * <code>invoke()</code> method with a generic signature. It also demands that
32 * invokable objects must be able to return a list of dependencies they require.
33 * </p>
34 *
35 * @author Oliver Heger
36 * @version $Id: Invokable.java 205 2012-01-29 18:29:57Z oheger $
37 */
38 public interface Invokable
39 {
40 /**
41 * Returns a list with all dependencies required for this invocation.
42 * Typically these dependencies define the parameters for the method call to
43 * be performed.
44 *
45 * @return a list with the dependencies required by this invocation
46 */
47 List<Dependency> getParameterDependencies();
48
49 /**
50 * Performs the invocation. This is the main method of an
51 * <code>Invokable</code> object, which actually executes a method. The
52 * passed in parameters should satisfy all requirements of an arbitrary
53 * invocation. Some of them may not be needed for a concrete invocation
54 * (e.g. a constructor invocation does not require a target object).
55 *
56 * @param depProvider the dependency provider, which can be used for
57 * resolving the parameter dependencies
58 * @param target the target object, on which the invocation should be
59 * performed
60 * @return the result of the invocation
61 */
62 Object invoke(DependencyProvider depProvider, Object target);
63 }