Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c4fb74cf8bc7850611cecc42d9eb9e845a5e93bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*******************************************************************************
 * Copyright (c) 2010, 2017 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.osgi.internal.serviceregistry;

import org.osgi.framework.ServiceRegistration;

/**
 * A callable hook that contains the context for call a collection of hooks.
 * This is effectively a "closure" for calling each hook. The hook context
 * must know the type of the hook object, the method to call on the hook
 * as well as all the parameters which need to be passed to the hook method.
 *
 */
public interface HookContext {

	/**
	 * Call the specified hook.
	 * 
	 * @param hook The hook object to call. The hook object must be of the type
	 * supported by this hook context. If it is not, then this method will
	 * simply return.
	 * @param hookRegistration the registration for the hook object
	 * @throws Exception An exception thrown by the hook object.
	 */
	public void call(Object hook, ServiceRegistration<?> hookRegistration) throws Exception;

	/**
	 * Return the class name of the hook type supported by this hook context.
	 * 
	 * @return The class name of the hook type supported by this hook context.
	 */
	public String getHookClassName();

	/**
	 * Return the hook method name called by this hook context.
	 * 
	 * @return The hook method name called by this hook context.
	 */
	public String getHookMethodName();

	/**
	 * Returns true if the given registration should be skipped.
	 * @param hookRegistration the registration to check
	 * @return true if the given registration should be skipped.
	 */
	public boolean skipRegistration(ServiceRegistration<?> hookRegistration);
}

Back to the top