KickJava   Java API By Example, From Geeks To Geeks.

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


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.security.ProtectionDomain JavaDoc;
15 import java.util.ArrayList JavaDoc;
16 import org.eclipse.osgi.baseadaptor.BaseData;
17 import org.eclipse.osgi.baseadaptor.HookRegistry;
18 import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
19 import org.eclipse.osgi.baseadaptor.loader.*;
20 import org.eclipse.osgi.framework.adaptor.*;
21
22 /**
23  * A ClassLoadingHook hooks into the <code>ClasspathManager</code> class.
24  * @see ClasspathManager
25  * @see HookRegistry#getClassLoadingHooks()
26  * @see HookRegistry#addClassLoadingHook(ClassLoadingHook)
27  * @since 3.2
28  */

29 public interface ClassLoadingHook {
30     /**
31      * Gets called by a classpath manager before defining a class. This method allows a class loading hook
32      * to process the bytes of a class that is about to be defined.
33      * @param name the name of the class being defined
34      * @param classbytes the bytes of the class being defined
35      * @param classpathEntry the ClasspathEntry where the class bytes have been read from.
36      * @param entry the BundleEntry source of the class bytes
37      * @param manager the class path manager used to define the requested class
38      * @return a modified array of classbytes or null if the original bytes should be used.
39      */

40     byte[] processClass(String JavaDoc name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager);
41
42     /**
43      * Gets called by a classpath manager when looking for ClasspathEntry objects. This method allows
44      * a classloading hook to add additional ClasspathEntry objects
45      * @param cpEntries the list of ClasspathEntry objects currently available for the requested classpath
46      * @param cp the name of the requested classpath
47      * @param hostmanager the classpath manager the requested ClasspathEntry is for
48      * @param sourcedata the source bundle data of the requested ClasspathEntry
49      * @param sourcedomain the source domain of the requested ClasspathEntry
50      * @return true if a ClasspathEntry has been added to cpEntries
51      */

52     boolean addClassPathEntry(ArrayList JavaDoc cpEntries, String JavaDoc cp, ClasspathManager hostmanager, BaseData sourcedata, ProtectionDomain JavaDoc sourcedomain);
53
54     /**
55      * Gets called by a base data during {@link BundleData#findLibrary(String)}.
56      * A base data will call this method for each configured class loading hook until one
57      * class loading hook returns a non-null value. If no class loading hook returns
58      * a non-null value then the base data will return null.
59      * @param data the base data to find a native library for.
60      * @param libName the name of the native library.
61      * @return The absolute path name of the native library or null.
62      */

63     String JavaDoc findLibrary(BaseData data, String JavaDoc libName);
64
65     /**
66      * Gets called by the adaptor during {@link FrameworkAdaptor#getBundleClassLoaderParent()}.
67      * The adaptor will call this method for each configured class loading hook until one
68      * class loading hook returns a non-null value. If no class loading hook returns
69      * a non-null value then the adaptor will perform the default behavior.
70      * @return the parent classloader to be used by all bundle classloaders or null.
71      */

72     public ClassLoader JavaDoc getBundleClassLoaderParent();
73
74     /**
75      * Gets called by a base data during
76      * {@link BundleData#createClassLoader(ClassLoaderDelegate, BundleProtectionDomain, String[])}.
77      * The BaseData will call this method for each configured class loading hook until one data
78      * hook returns a non-null value. If no class loading hook returns a non-null value then a
79      * default implemenation of BundleClassLoader will be created.
80      * @param parent the parent classloader for the BundleClassLoader
81      * @param delegate the delegate for the bundle classloader
82      * @param domain the domian for the bundle classloader
83      * @param data the BundleData for the BundleClassLoader
84      * @param bundleclasspath the classpath for the bundle classloader
85      * @return a newly created bundle classloader
86      */

87     BaseClassLoader createClassLoader(ClassLoader JavaDoc parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, String JavaDoc[] bundleclasspath);
88
89     /**
90      * Gets called by a classpath manager at the end of
91      * {@link ClasspathManager#initialize()}.
92      * The classpath manager will call this method for each configured class loading hook after it
93      * has been initialized.
94      * @param baseClassLoader the newly created bundle classloader
95      * @param data the BundleData associated with the bundle classloader
96      */

97     void initializedClassLoader(BaseClassLoader baseClassLoader, BaseData data);
98 }
99
Popular Tags