KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ungoverned > moduleloader > LibrarySource


1 /*
2  * ModuleLoader - A generic, policy-driven class loader.
3  * Copyright (c) 2004, Richard S. Hall
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of the ungoverned.org nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * Contact: Richard S. Hall (heavy@ungoverned.org)
33  * Contributor(s):
34  *
35 **/

36 package org.ungoverned.moduleloader;
37
38 /**
39  * <p>
40  * This interface represents a source for obtaining native libraries for a
41  * given module via the module's class loader. The main goal of a library
42  * source is to map a library name to a path in the file system.
43  * </p>
44  * <p>
45  * All library sources are initialized before first usage via a call
46  * to the <a HREF="#open()"><tt>LibrarySource.open()</tt></a> method and
47  * are also deinitialized via a call to
48  * <a HREF="#open()"><tt>LibrarySource.close()</tt></a>. Library sources
49  * should be implemented such that they can be opened, closed, and then
50  * re-opened.
51  * </p>
52  * @see org.ungoverned.moduleloader.Module
53  * @see org.ungoverned.moduleloader.ModuleClassLoader
54 **/

55 public interface LibrarySource
56 {
57     /**
58      * <p>
59      * This method initializes the library source. It is called when
60      * the associated module is added to the <tt>ModuleManager</tt>. It
61      * is acceptable for implementations to ignore duplicate calls to this
62      * method if the library source is already opened.
63      * </p>
64     **/

65     public void open();
66
67     /**
68      * <p>
69      * This method de-initializes the library source. It is called when
70      * the associated module is removed from the <tt>ModuleManager</tt> or
71      * when the module is reset by the <tt>ModuleManager</tt>.
72      * </p>
73     **/

74     public void close();
75
76     /**
77      * <p>
78      * Returns a file system path to the specified library.
79      * </p>
80      * @param name the name of the library that is being requested.
81      * @return a file system path to the specified library.
82      * @throws java.lang.IllegalStateException if the resource source has not
83      * been opened.
84     **/

85     public String JavaDoc getPath(String JavaDoc name) throws IllegalStateException JavaDoc;
86 }
Popular Tags