KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > baseadaptor > hooks > AdaptorHook


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.osgi.baseadaptor.hooks;
13
14 import java.io.IOException JavaDoc;
15 import java.net.URLConnection JavaDoc;
16 import java.util.Properties JavaDoc;
17 import org.eclipse.osgi.baseadaptor.BaseAdaptor;
18 import org.eclipse.osgi.baseadaptor.HookRegistry;
19 import org.eclipse.osgi.framework.adaptor.EventPublisher;
20 import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
21 import org.eclipse.osgi.framework.log.FrameworkLog;
22 import org.osgi.framework.BundleContext;
23 import org.osgi.framework.BundleException;
24
25 /**
26  * An AdaptorHook hooks into the <code>BaseAdaptor</code> class.
27  * @see BaseAdaptor
28  * @see HookRegistry#getAdaptorHooks()
29  * @see HookRegistry#addAdaptorHook(AdaptorHook)
30  * @since 3.2
31  */

32 public interface AdaptorHook {
33     /**
34      * Gets called by the adaptor during {@link FrameworkAdaptor#initialize(EventPublisher)}.
35      * This method allows an adaptor hook to save the adaptor object for later.
36      * @param adaptor the adaptor object associated with this AdaptorHook.
37      */

38     public void initialize(BaseAdaptor adaptor);
39
40     /**
41      * Gets called by the adaptor during {@link FrameworkAdaptor#frameworkStart(BundleContext)}.
42      * This method allows an adaptor hook to execute code when the framework is starting
43      * (e.g. to register services).
44      * @param context the system bundle context
45      * @throws BundleException if an error occurs
46      */

47     public void frameworkStart(BundleContext context) throws BundleException;
48
49     /**
50      * Gets called by the adaptor during {@link FrameworkAdaptor#frameworkStop(BundleContext)}.
51      * This method allows an adaptor hook to execute code when the framework is stopped
52      * (e.g. to unregister services).
53      * @param context the system bundle context
54      * @throws BundleException if an error occurs.
55      */

56     public void frameworkStop(BundleContext context) throws BundleException;
57
58     /**
59      * Gets called by the adaptor during {@link FrameworkAdaptor#frameworkStopping(BundleContext)}.
60      * This method allows an adaptor hook to execute code when the framework is about to start
61      * the shutdown process.
62      * @param context the system bundle context
63      */

64     public void frameworkStopping(BundleContext context);
65
66     /**
67      * Gets called by the adaptor during {@link FrameworkAdaptor#getProperties()}.
68      * This method allows an adaptor hook to add property values to the adaptor
69      * properties object.
70      * @param properties the adaptor properties object.
71      */

72     public void addProperties(Properties JavaDoc properties);
73
74     /**
75      * Gets called by the adaptor during {@link FrameworkAdaptor#mapLocationToURLConnection(String)}.
76      * The adaptor will call this method for each configured adaptor hook until one
77      * adaptor hook returns a non-null value. If no adaptor hook returns a non-null value
78      * then the adaptor will perform the default behavior.
79      * @param location a bundle location string to be converted to a URLConnection
80      * @return the URLConnection converted from the bundle location or null.
81      * @throws IOException if an error occured creating the URLConnection
82      */

83     public URLConnection JavaDoc mapLocationToURLConnection(String JavaDoc location) throws IOException JavaDoc;
84
85     /**
86      * Gets called by the adaptor during {@link FrameworkAdaptor#handleRuntimeError(Throwable)}.
87      * The adaptor will call this method for each configured adaptor hook.
88      * @param error the unexpected error that occured.
89      */

90     public void handleRuntimeError(Throwable JavaDoc error);
91
92     /**
93      * Gets called by the adaptor during {@link FrameworkAdaptor#matchDNChain(String, String[])}.
94      * The adaptor will call this method for each configured adaptor hook until one
95      * adaptor hook returns a true value. If no adaptor hook returns a true value
96      * then the adaptor will return false.
97      * @param pattern A
98      * @param dnChain
99      * @return true if the pattern matches
100      */

101     public boolean matchDNChain(String JavaDoc pattern, String JavaDoc[] dnChain);
102
103     /**
104      * Gets called by the adaptor during {@link FrameworkAdaptor#getFrameworkLog()}.
105      * The adaptor will call this method for each configured adaptor hook until one
106      * adaptor hook returns a non-null value. If no adaptor hook returns a non-null value
107      * then the adaptor will return null.
108      * @return a FrameworkLog object or null.
109      */

110     public FrameworkLog createFrameworkLog();
111 }
112
Popular Tags